示例#1
0
        public async Task <Stream> DownloadPackageFileToDiskAsync(PackageValidationSet validationSet, string sasDefinition)
        {
            Uri fileUri = null;

            if (string.IsNullOrEmpty(sasDefinition))
            {
                fileUri = await GetPackageReadUriAsync(validationSet);
            }
            else
            {
                var sasToken = await _sharedAccessSignatureService.GetFromManagedStorageAccountAsync(sasDefinition);

                var packageUri = await GetPackageUriAsync(validationSet);

                fileUri = new Uri(packageUri, sasToken);
            }

            var result = await _fileDownloader.DownloadAsync(fileUri, CancellationToken.None);

            return(result.GetStreamOrThrow());
        }
        public async Task <Uri> GetReadAndDeleteUriAsync(
            string packageId,
            string packageNormalizedVersion,
            Guid validationId,
            string sasDefinition)
        {
            var fileName = BuildFileName(packageId, packageNormalizedVersion, validationId);

            if (string.IsNullOrEmpty(sasDefinition))
            {
                return(await _fileStorageService.GetPriviledgedFileUriAsync(
                           CoreConstants.Folders.ValidationFolderName,
                           fileName,
                           FileUriPermissions.Read | FileUriPermissions.Delete,
                           DateTimeOffset.UtcNow + AccessDuration));
            }

            var fileUri = await _fileStorageService.GetFileUriAsync(CoreConstants.Folders.ValidationFolderName, fileName);

            var sasToken = await _sharedAccessSignatureService.GetFromManagedStorageAccountAsync(sasDefinition);

            return(new Uri(fileUri, sasToken));
        }