AWS S3 headObject method doesn't return custom metadata in response

May 10, 2019 649 views
API Object Storage

So I’m trying to get some of the metadata from Spaces but when I use headObject() from the S3 javascript library I get an empty metadata: {} object.

Using postman I can see my custom metadata in there when using the call referenced in the documentation but it doesn’t come through the S3 library.

1 Answer

The HEAD operation retrieves metadata from an object without returning the object itself. This operation is useful if you are interested only in an object’s metadata. To use HEAD, you must have READ access to the object.

A HEAD request has the same options as a GET operation on an object. The response is identical to the GET response except that there is no response body.

If you encrypt an object by using server-side encryption with customer-provided encryption keys (SSE-C) when you store the object in Amazon S3, then when you retrieve the metadata from the object, you must use the headers documented in the section Specific Request Headers for Server-Side Encryption with Customer-Provided Encryption Keys . For more information about SSE-C, go to Server-Side Encryption (Using Customer-Provided Encryption Keys) in the Amazon Simple Storage Service Developer Guide.

Permissions

  • The content in question is public and isn’t encrypted. The only thing that I’ve secured atm is listing the buckets contents. but the objects in the bucket are public. So I don’t think that this applies to this scenario.

    This is what the response looks like when I try to get all the data about the object from listObjectsV2 and headObject.
    You’ll note that the metadata object is empty.

    {
    ContentLength: 36642254,
    
    ContentType: "audio/wav",
    
    ETag: "\"REDACTED\"",
    
    Key: "REDACTED",
    
    LastModified: Thu May 09 2019 20:56:24 GMT-0600 (MDT),
    
    Metadata: {},
    
    Owner: {DisplayName: "REDACTED", ID: "REDACTED"},
    
    Size: 36642254,
    
    StorageClass: "STANDARD",
    }
    
Have another answer? Share your knowledge.