In the article, we will see how to upload the metadata of an object while uploading it to S3 programmatically with Node.js.
Before jumping to that, let’s see what is metadata and its use cases.
We have two types of metadata:
- System Metadata (e.g. Date, Content-Length).
- User-defined metadata.
While we upload the object, we can add custom metadata about the object as a key-value pair.
Note: All user–defined metadata keys must be in lowercase.
Let’s say we are having a platform where content is added by multiple organizations. In this scenario, adding OrganizationID as one of the metadata will be handy.
The following code helps you to upload an object to s3, along with its metadata.
Let’s see how to retrieve the metadata of an uploaded object using Node.js.
You may also like:
AWS S3 Bucket Naming Challenge [Comic].
The following code helps you to retrieve the metadata of an object uploaded to an s3.
Note: The PUT request header is limited to 8 KB in size. Within the PUT request header, the user-defined metadata is limited to 2 KB in size. The size of user-defined metadata is measured by taking the sum of the number of bytes in the UTF-8 encoding of each key and value.
I hope this helps!