How to Set File Metadata

Spaces Object Storage is an S3-compatible object storage service. Spaces buckets let you store and serve large amounts of data, and the built-in CDN minimizes page load times and improves performance.


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

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-Encoding may be modified by the server, for example to convert pre-compressed content for a client that does not support compression.

  • 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 invalidation.

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.

Note

Origin endpoints do not dynamically compress or decompress content, and they do not modify the content’s Content-Encoding header. However, for files downloaded via the CDN, you can set the following metadata headers during upload to the origin to make the CDN dynamically compress or decompress the file:

  • The CDN endpoints may dynamically compress content, if the origin object does not have Content-Encoding: gzip and the client sends Accept-Encoding: gzip. If dynamically compressed, the resulting response has the Content-Encoding: gzip header added.

  • The CDN endpoints may dynamically decompress content if the origin object has Content-Encoding: gzip and the client does not send Accept-Encoding: gzip. If dynamically uncompressed, the resulting response has the Content-Encoding: gzip header removed.

Similar behavior also applies to other major S3 and CDN vendors.