Managing Object Metadata
Simple Object Storage (or SOS) allows you to separate file metadata from data. Each object in a bucket can be tagged with key-value pairs. This metadata is presented through HTTP headers on SOS requests and responses.
Add Metadata
From the the Portal:
- Click on STORAGE in the main navigation.
- Select your bucket.
- Click on on the pencil icon of the object to edit.
- Click on on the Metadata tab.
You can add key-value pairs, assigned to the object you chose.
From the CLI:
We assume you are using S3cmd.
The modify
command modifies the metadata.
You can then use the option --add-header
to add an HTTP header.
The headers that start with x-amz-meta
will be seen as metadata.
If you want to add a metadata “foo” with value “bar”, the key will be named x-amz-meta-foo
$ s3cmd modify --add-header x-amz-meta-foo:bar s3://<bucket>/<object>
modify: 's3://<bucket>/<object>'
View Metadata
From the Portal:
To view the metadata associated with an object, you need to edit the object:
- Click on STORAGE in the main navigation.
- Select your bucket.
- Click on on the pencil icon of the object to edit.
- Click on on the Metadata tab.
From the CLI:
We assume for this example you are using S3cmd.
The info
command will return information on an object, including its metadata.
$ s3cmd info s3://<bucket>/<object>/
s3://<bucket>/<object>/ (object):
File size: 0
Last mod: Mon, 02 Nov 2015 13:37:00 UTC
MIME type: application/binary
MD5 sum: d41d8cd98f00b204e9800998ecf8427e
SSE: none
policy: none
cors: <?xml version="1.0" encoding="UTF-8"?><CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"></CORSConfiguration>
ACL: None: FULL_CONTROL
x-amz-meta-test: true
x-amz-meta-foo: bar
You can see 2 key-value pairs for this object:
test
was set totrue
.foo
was set tobar
.
Delete Metadata
From the Portal:
To delete the metadata associated with an object, you need to edit the object:
- Click on STORAGE in the main navigation.
- Select your bucket.
- Click on on the pencil icon of the object to edit.
- Click on on the Metadata tab.
Then, for each key-value pair, you can click on the X icon to delete.
From the CLI:
We assume you are using S3cmd.
The modify
command modifies the metadata.
You can then use the option --remove-header
to delete an HTTP header.
The metadata starts with x-amz-meta
. So as an example, if you want to remove the metadata
“foo” with value “bar”, you should remove x-amz-meta-foo
:
$ s3cmd modify --remove-header x-amz-meta-foo s3://<bucket>/<object>
modify: 's3://<bucket>/<object>'