How to Set File Metadata

Spaces is an S3-compatible object storage service that lets you store and serve large amounts of data. Each Space is a bucket for you to store and serve files. The free, built-in Spaces CDN minimizes page load times, improves performance, and reduces bandwidth and infrastructure costs.

In an individual file’s More menu, you can Manage Metadata for the file. You can also manage metadata for multiple files at once by selecting them, opening the Actions menu, and choosing Manage Metadata.

The metadata window for a file
Due to a known issue, file metadata headers like Content-Encoding are not passed through the CDN. Metadata headers are correctly set when fetching content directly from the origin.

Manage Metadata lets you set the following four attributes and add custom key-value pairs:

  • Content-Type, also known as the MIME type, helps browsers render content properly. Most of the time, this is automatically detected, but it can be overridden if needed. For a detailed discussion, see Content-Type.

  • Cache-Control determines how long web browsers and Internet caches can store a copy of the object, an important metadata item for CDN configuration. The cache time values are specified in seconds. For a detailed discussion, see Web Caching Basics: Terminology, HTTP Headers, and Caching Strategies.

  • Content-Encoding indicates if a file is being compressed in transit. For a detailed discussion, see Content Encoding.

  • Content-Disposition indicates if a regular file should be displayed inline in the web browser or downloaded as an attachment. For detailed discussion, see Content-Disposition.

  • Add Custom Pairing allows you to set your own key-value headers. For example, if you are using Spaces with certain CDNs or reverse proxies, you might use the x-amz-meta-surrogate-key to assist with selective cache invalidations.

If you use s3cmd or the Spaces API, you can also set a file’s metadata when you upload it. There are more specific instructions for s3mcd in Examples of s3cmd 2.x Usage with DigitalOcean Spaces and for Spaces API on the Spaces API Documentation.