public async Task <GetBlobResponse> GetBlobAsync(string containerName, string blobName, BlobRange range = null, string leaseId = null) { var request = new GetBlobRequest(_account, containerName, blobName, range, leaseId); var response = await request.ExecuteAsync(); return(response.Payload); }
internal virtual GetBlobResponse GetBlob(GetBlobRequest request) { var marshaller = new GetBlobRequestMarshaller(); var unmarshaller = GetBlobResponseUnmarshaller.Instance; return(Invoke <GetBlobRequest, GetBlobResponse>(request, marshaller, unmarshaller)); }
public GetBlobResponse GetBlob(string containerName, string blobName, BlobRange range = null, string leaseId = null) { var request = new GetBlobRequest(_account, containerName, blobName, range, leaseId); var response = request.Execute(); return(response.Payload); }
public Task <IGetBlobStrategy> CreateGetBlobStrategyAsync(GetBlobRequest getBlobRequest) { getBlobRequest.ValidateArgument(nameof(getBlobRequest)); var container = cloudBlobClient.GetContainerReference(getBlobRequest.ContainerName.ToLower()); var blob = container.GetBlockBlobReference(getBlobRequest.BlobName); var sasStartTime = DateTime.UtcNow.Add(urlStartOffset); var sasExpirationTime = DateTime.UtcNow.Add(urlDuration); var sasBlobPolicy = new SharedAccessBlobPolicy { SharedAccessStartTime = sasStartTime, SharedAccessExpiryTime = sasExpirationTime, Permissions = SharedAccessBlobPermissions.Read }; var strategyConfiguration = new HttpGetBlobConfiguration { Url = (blob.Uri + blob.GetSharedAccessSignature(sasBlobPolicy)), UrlExpirationUtc = sasExpirationTime }; return(Task.FromResult(new HttpGetBlobStrategy(strategyConfiguration) as IGetBlobStrategy)); }
private async Task <byte[]> GetBlobAsyncWorker(ulong id, CancellationToken cancellationToken) { await TaskUtilities.SwitchToBackgroundThread(); var request = await GetBlobRequest.SendAsync(this, id, cancellationToken); return(await request.Task); }
/// <summary> /// Initiates the asynchronous execution of the GetBlob operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the GetBlob operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/codecommit-2015-04-13/GetBlob">REST API Reference for GetBlob Operation</seealso> public virtual Task <GetBlobResponse> GetBlobAsync(GetBlobRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new GetBlobRequestMarshaller(); var unmarshaller = GetBlobResponseUnmarshaller.Instance; return(InvokeAsync <GetBlobRequest, GetBlobResponse>(request, marshaller, unmarshaller, cancellationToken)); }
/// <summary> /// Retrieves a blob from the server. /// </summary> /// <param name="blobId">the blob id</param> /// <returns>the blob</returns> public Task <Blob> GetBlob(string blobId) { var request = new GetBlobRequest { BlobId = blobId }; return(gateway(authenticationContext()).GetBlobAsync(request) .ToTask(response => response.Blob)); }
public async Task <Stream> GetBlobAsync(GetBlobRequest getBlobRequest) { getBlobRequest.ValidateArgument(nameof(getBlobRequest)); var strategyDefinition = await storageServiceProxy.GetGetBlobStrategyDefinitionAsync(getBlobRequest); var getBlobStrategy = await getBlobStrategyFactory.CreateStrategyAsync(strategyDefinition); return(await getBlobStrategy.GetBlobAsync()); }
public static async Task <GetBlobRequest> SendAsync(RHost host, ulong blobId, CancellationToken cancellationToken) { var message = host.CreateMessage("?GetBlob", ulong.MaxValue, new JArray { blobId }); var request = new GetBlobRequest(host, message, cancellationToken); await host.SendAsync(message, cancellationToken); return(request); }
/// <summary> /// Retrieves a blob from the server. /// </summary> /// <param name="blobId">id of the blob</param> /// <returns>Blob</returns> public Task <Blob> GetBlob(string blobId) { var request = new GetBlobRequest { BlobId = blobId }; return(gateway.GetBlobAsync(request) .ToTask(response => response.Blob)); }
public async Task <IActionResult> GetBlob(string containerName, string blobName) { if (string.IsNullOrEmpty(blobName)) { return(BadRequest($"Blob name is required (e.g., 'http://.../get-blob/{containerName}/[blobName]').")); } var getBlobRequest = new GetBlobRequest(containerName, blobName); var getBlobStrategy = await storageStrategyProvider.CreateGetBlobStrategyAsync(getBlobRequest); return(new ObjectResult(getBlobStrategy)); }
public Task <GetBlobResponse> GetBlobAsync(GetBlobRequest request, CallContext callContext = default) { return(ExecuteAsync(request, callContext, context => { return _store.GetBlobAsync(context, request.ContentHash) .SelectAsync(r => new GetBlobResponse() { Blob = r.Blob, }); }, extraEndMessage: r => { if (!r.Succeeded) { return $"Hash=[{request.ContentHash}]"; } return $"Hash=[{request.ContentHash}] Size=[{r.Value.Blob?.Length ?? -1}]"; })); }
public Task <IGetBlobStrategy> CreateGetBlobStrategyAsync(GetBlobRequest getBlobRequest) { getBlobRequest.ValidateArgument(nameof(getBlobRequest)); var expirationTimeUtc = DateTime.UtcNow.Add(urlDuration); var getBlobUrl = urlSigner.Sign( getBlobRequest.ContainerName, getBlobRequest.BlobName, expirationTimeUtc, HttpMethod.Get); var strategyConfiguration = new HttpGetBlobConfiguration { Url = getBlobUrl, UrlExpirationUtc = expirationTimeUtc }; return(Task.FromResult(new HttpGetBlobStrategy(strategyConfiguration) as IGetBlobStrategy)); }
public Task <IGetBlobStrategy> CreateGetBlobStrategyAsync(GetBlobRequest getBlobRequest) { getBlobRequest.ValidateArgument(nameof(getBlobRequest)); var urlExpirationTime = DateTime.UtcNow.Add(urlDuration); var urlRequest = new GetPreSignedUrlRequest { BucketName = getBlobRequest.ContainerName, Expires = urlExpirationTime, Key = getBlobRequest.BlobName, Protocol = Protocol.HTTPS, Verb = HttpVerb.GET }; var strategyConfiguration = new HttpGetBlobConfiguration { Url = s3Client.GetPreSignedURL(urlRequest), UrlExpirationUtc = urlExpirationTime }; return(Task.FromResult(new HttpGetBlobStrategy(strategyConfiguration) as IGetBlobStrategy)); }
public async Task <StorageStrategyDefinition> GetGetBlobStrategyDefinitionAsync(GetBlobRequest getBlobRequest) { getBlobRequest.ValidateArgument(nameof(getBlobRequest)); var relativeUrl = new Uri($"/get-blob/{getBlobRequest.ContainerName}/{getBlobRequest.BlobName}", UriKind.Relative); var response = await httpClient.GetStringAsync(new Uri(baseUrl, relativeUrl)).ConfigureAwait(false); return(JsonConvert.DeserializeObject <StorageStrategyDefinition>(response)); }