Skip to content

Commit

Permalink
fix GetObjectAsync api call to check if object is present (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
poornas authored and nitisht committed Dec 18, 2018
1 parent 1f271e5 commit 0c900a9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Minio/ApiEndpoints/ObjectOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public partial class MinioClient : IObjectOperations
/// <param name="cancellationToken">Optional cancellation token to cancel the operation</param>
public async Task GetObjectAsync(string bucketName, string objectName, Action<Stream> cb, CancellationToken cancellationToken = default(CancellationToken))
{
await StatObjectAsync(bucketName, objectName, cancellationToken).ConfigureAwait(false);

var request = await this.CreateRequest(Method.GET,
bucketName,
objectName: objectName)
Expand All @@ -73,6 +75,9 @@ public async Task GetObjectAsync(string bucketName, string objectName, long offs
throw new ArgumentException("Offset should be zero or greater");
if (length < 0)
throw new ArgumentException("Length should be greater than zero");

await StatObjectAsync(bucketName, objectName, cancellationToken).ConfigureAwait(false);

Dictionary<string, string> headerMap = new Dictionary<string, string>();
if (length > 0)
headerMap.Add("Range", "bytes=" + offset.ToString() + "-" + (offset + length - 1).ToString());
Expand Down

0 comments on commit 0c900a9

Please sign in to comment.