question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

C# SDK: How to determine if GetObjectAsync succeeded?

See original GitHub issue

When accessing an object with a key that does not exist, the stream provided by GetObjectAsync contains an XML error and does not throw and error when read, How should a caller avoid returning this XML error string in place of an actual string? I realize it is possible to call StatObjectAsync first, but that raises concerns about what happens if stat is called first, then before getobject a remove call is made.

Expected Behavior

I would expect an exception from GetObjectAsync if the object could not be retrieved.

Current Behavior

The stream contains an XML string:

<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Resource>/storagetest.f7f3da7a3a0b4ff299794b47161dccf6/Key Not Found</Resource><RequestId>15704FE60F942D64</RequestId><HostId>3L137</HostId></Error>

Possible Solution

  • Provide a separate callback for the missing object scenario
  • Provide a null stream
  • Throw an exception

Steps to Reproduce (for bugs)

Call GetObjectAsync and provide a non-existing object key.

Context

I am concerned about concurrency problems with remove operations.

Your Environment

  • Version used (minio version): 2018-12-13T02:04:19Z
  • Environment name and version (e.g. nginx 1.9.1): n/a
  • Server type and version: n/a
  • Operating System and version (uname -a): Windows 10
  • Link to your project: n/a

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
nitishtcommented, Dec 18, 2018

fixed by #260

1reaction
poornascommented, Dec 14, 2018

ok, I see a bug in this GetObjectAsync api call where we are not doing a stat prior to fetching - will fix it.

 public async Task GetObjectAsync(string bucketName, string objectName, long offset, long length, Action<Stream> cb, ServerSideEncryption sse = null,CancellationToken cancellationToken = default(CancellationToken))

The other API call should work -

 public async Task GetObjectAsync(string bucketName, string objectName, string fileName,ServerSideEncryption sse = null, CancellationToken cancellationToken = default(CancellationToken))

Read more comments on GitHub >

github_iconTop Results From Across the Web

AmazonS3Client.GetObjectAsync (GetObjectRequest, ...
Retrieves objects from Amazon S3. To use GET , you must have READ access to the object. If you grant READ access to...
Read more >
Intermittent hang on S3 GetObjectAsync when called from ...
I am experiencing an issue where it appears that the GetObjectAsync call to retrieve the S3 object intermittently hangs.
Read more >
c# - Determine if an object exists in a S3 bucket based on ...
I used the following code in C# with Amazon S3 version 3.1.5(.net 3.5) to check if the bucket exists: BasicAWSCredentials credentials = new ......
Read more >
Upload/Download/Delete Files From AWS S3 Using .NET ...
In this article, we are going to explore about how to upload, download and delete the file(s) from AWS S3 and check if...
Read more >
WMI Provider Log Files - Win32 apps
Verify that your computer is a member of a domain. CDSClassProvider::GetObjectAsync() GetClassFromCacheOrADSI FAILED for <class name> with ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found