How can I get the MIME types of objects in Amazon S3?

.net, amazon-s3, amazon-web-services

Solution

The REST API offers the HEAD Object operation for this purpose and the AWS SDK for .NET conveniently wraps the very same functionality via the GetObjectMetadata() method:

The GetObjectMetadata operation is used to retrieve information about a specific object or object size, without actually fetching the object itself. This is useful if you're only interested in the object metadata, and don't want to waste bandwidth on the object data. The response is identical to the GetObject response, except that there is no response body. [emphasis mine]

Problem

Is there a way to retrieve the MIME types of the objects in S3. I am trying to implement a solution in which I will be getting multiple objects from S3. Instead of using there key and then getting a sub string to calculate the MIME type, can I get the MIME type from Amazon S3 in some way? I am using cloud berry explorer pro and I know it let's you set the MIME type, but how do we retrieve this information using the AWS SDK for .NET or the REST API?

Original source