From 0c900a9a736f095c6bfcc7b2240c65cce80950c6 Mon Sep 17 00:00:00 2001 From: poornas Date: Tue, 18 Dec 2018 01:26:39 -0800 Subject: [PATCH] fix GetObjectAsync api call to check if object is present (#260) --- Minio/ApiEndpoints/ObjectOperations.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Minio/ApiEndpoints/ObjectOperations.cs b/Minio/ApiEndpoints/ObjectOperations.cs index c5eb15b75..9b9aedc0c 100644 --- a/Minio/ApiEndpoints/ObjectOperations.cs +++ b/Minio/ApiEndpoints/ObjectOperations.cs @@ -47,6 +47,8 @@ public partial class MinioClient : IObjectOperations /// Optional cancellation token to cancel the operation public async Task GetObjectAsync(string bucketName, string objectName, Action cb, CancellationToken cancellationToken = default(CancellationToken)) { + await StatObjectAsync(bucketName, objectName, cancellationToken).ConfigureAwait(false); + var request = await this.CreateRequest(Method.GET, bucketName, objectName: objectName) @@ -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 headerMap = new Dictionary(); if (length > 0) headerMap.Add("Range", "bytes=" + offset.ToString() + "-" + (offset + length - 1).ToString());