How to Set File Metadata

Spaces Object Storage 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 built-in Spaces 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 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.


Origin endpoints do not dynamically compress or uncompress 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 uncompress 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 uncompress 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.