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

Posted May 10, 2019 4.1k views
APIObject 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.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
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.


  • 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",