Skip to content

C# Checking the results of AWS GetObject

0

When using IAmazonS3.GetObjectAsync() the response includes HttpStatusCode and checksum.

I've looked at several examples but none of them are checking the HttpStatusCode or checksum.

Should I verify the results of HttpStatusCode and checksum or does that happen automatically?

If it's automatic what happens if HttpStatusCode is not OK or checksum is not equal? Does it throw an exception and if so what kind of exception?

asked 2 years ago973 views

2 Answers
1

I would imagine the examples that you see are brief and specific and should not be regarded as full, production ready examples. As you are aware, it is always best to ensure you check results and handle errors appropriately.

Expect the unexpected and handle accordingly.

Hope this helps!

AWS
EXPERT

answered 2 years ago

0

After some testing I found that if HttpStatusCode is anything other then something in the 200 range, AmazonS3Client methods will throw an AmazonS3Exception with a helpful message. There really is no need to check HttpStatusCode in the response object unless you want to check which of the OK status types you are getting (OK, No content, etc.).

I don't know if AmazonS3Client methods internally check the checksum but it still should be checked after saving the file to disk to ensure it's save correctly.

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.