For AI agents: The documentation index is at https://docs.digitalocean.com/llms.txt. Markdown versions of pages use the same URL with index.html.md in place of the HTML page (for example, append index.html.md to the directory path instead of opening the HTML document).
To manage metadata for a file, go to the Control Panel, in the left menu, click STORAGE, click Spaces Object Storage, click the bucket with the file you want to manage metadata for. In the Files tab, find the file you need, and then on the right, click …, and then click Manage Metadata to open the Manage Metadata editor window.
In the Files tab, you can either update a singular file or multiple files:
- For a singular file, on the right of the file, click …, and then click Manage Metadata to open the Manage Metadata editor window.
- To change permissions for multiple files at once, click the checkbox on the left of all the files you want to edit, and then in the top-right, click Actions, and then click Manage Metadata to open the Manage Metadata editor window.
Origin endpoints don’t dynamically compress or decompress content, and they don’t modify the Content-Encoding header.
CDN endpoints can change how content is delivered based on the object’s metadata and the client’s Accept-Encoding header:
- If the origin object doesn’t have
Content-Encoding: gzip and the client sends Accept-Encoding: gzip, the CDN may compress the response and add Content-Encoding: gzip.
- If the origin object has
Content-Encoding: gzip and the client doesn’t send Accept-Encoding: gzip, the CDN may decompress the response and remove the Content-Encoding: gzip header.
Similar behavior exists with other major S3-compatible storage services and CDNs.
Set Standard Metadata Field Values Using Control Panel
You can set the following standard metadata field value fields:
-
Content-Type: Specifies the file’s MIME type so browsers and other clients can handle the content correctly. Spaces usually detects this automatically, but you can override it when needed. For more information, see Content-Type.
-
Cache-Control: Controls how long browsers and other caches store a copy of the object. This is especially useful when you use Spaces with a CDN. Cache values are specified in seconds. For more information, see Web Caching Basics: Terminology, HTTP Headers, and Caching Strategies.
-
Content-Encoding: Indicates whether the file uses an encoding such as compression. For more information, see Content-Encoding.
-
Content-Disposition: Controls whether a file is displayed inline in the browser or downloaded as an attachment. For more information, see Content-Disposition.
After you set the standard metadata values, click Save, or continue to add custom metadata before saving.
Set Custom Metadata Key and Values
To set custom metadata, at the bottom of the key-value table, click Add Custom Pairing to open a new key-value row. For example, when you use Spaces with certain CDNs or reverse proxies, you might add x-amz-meta-surrogate-key to help with selective cache invalidation.
For Spaces Cold Storage, CDN-specific behavior doesn’t apply because CDN integration isn’t supported.
After you set your custom metadata, either add standard metadata field values, or click Save.
You can also set file metadata during upload by using an S3-compatible tool such as s3cmd or by sending requests to the Spaces S3-compatible API. This is useful when you want to set metadata as part of an automated upload workflow instead of editing it later in the control panel.
You can set both standard metadata headers, such as Content-Type and Cache-Control, and custom metadata headers.
To set file metadata with s3cmd, include metadata options when you upload the file.
For example, this command uploads a file and sets its Content-Type and Cache-Control metadata:
s3cmd put example.jpg s3://example-bucket/example.jpg \
--mime-type=image/jpeg \
--add-header="Cache-Control: max-age=3600"
For more s3cmd examples, see Examples of s3cmd 2.x Usage with DigitalOcean Spaces.
To set file metadata with the Spaces S3-compatible API, upload the object and include metadata headers in the request. Standard HTTP headers such as Content-Type, Cache-Control, Content-Encoding, and Content-Disposition are stored as object metadata. You can also set custom metadata by including headers that begin with x-amz-meta-.
For example, a request can include headers such as:
Content-Type: image/jpeg
Cache-Control: max-age=3600
Content-Disposition: inline
x-amz-meta-surrogate-key: example-key
For API details, see the Spaces API documentation.
To set file metadata with the AWS CLI, include metadata parameters in the upload command.
For example, this command uploads a file and sets its Content-Type and Cache-Control metadata:
aws s3api put-object \
--bucket example-bucket \
--key example.jpg \
--body example.jpg \
--content-type image/jpeg \
--cache-control "max-age=3600"
For more information, see the AWS CLI documentation for put-object.