Changing the Metadata of an Amazon S3 Object

Lab Steps

lock
Logging in to the Amazon Web Services Console
lock
Creating an Amazon S3 Bucket
lock
Creating a Folder inside an Amazon S3 Bucket
lock
Uploading a File to Amazon S3
lock
Granting Public Access to an Amazon S3 Object
lock
Changing the Metadata of an Amazon S3 Object
lock
Deleting an Amazon S3 Bucket
Need help? Contact our support team

Here you can find the instructions for this specific Lab Step.

If you are ready for a real environment experience please start the Lab. Keep in mind that you'll need to start from the first step.

Introduction

Each object in Amazon S3 has a set of key/value pairs representing its metadata. There are two types of metadata: "System metadata" (for example, Content-Type and Content-Length) and custom "User metadata". User metadata is stored with the object and returned with it.

As an example, you might have your own taxonomy for various images, such as “logo”, “screenshot”, “diagram”, "flowchart" and so on. In this lab step, you will change the Content-Type of your image to "text/plain". You will also create custom user metadata.

Note: With the new Amazon S3 UI you can set the metadata as part of the upload process, or add it later.

 

Instructions

1. Return to the cloudfolder/ and delete the cloudacademy-logo.png from your Amazon S3 bucket by checking the checkbox and clicking Delete:

alt

The Delete objects form page will load. Because a deleted object is not retrievable, AWS asks you to confirm that you want to delete the object before deletion.

 

2. In the textbox at the bottom of the page, enter permanently delete and click Delete objects:

alt

 

3. To return to the bucket object view, at the top-right, click Close.

 

4. Click Upload, then Add files and browse to the logo file (or drag-and-drop it into the Upload wizard) in order to upload it again.

  

5. Near the bottom of the page, expand the Properties section:

alt

 

6. Scroll down to the Metadata section and click Add metadata:

alt

 A row of form elements will appear.

 

7. Enter the following:

  • Type: Select System defined
  • Key: Select Content-Type
  • Value: Enter text/plain

alt

The drop-down list contains the System metadata that you can set.

In this lab, you have set the content type to text/plain as an example to see how to add metadata to an object when uploading to Amazon S3.

Next you will add custom user metadata. User metadata must be prefaced with "x-amz-meta-". The remaining instructions will add a custom user type for imagetype, and imagestatus.

 

8. Click Add metadata again to add another row. 

 

9. Enter the following to define custom metadata:

  • Type: Select User defined
  • Key: Enter imagetype after x-amz-meta
  • Value: Enter logo

alt

You have added two metadata key-value pairs to the object you are going to upload. One system metadata and one user-defined.

 

10. At the bottom of the page, click Upload:

alt

 

11. To exit the upload form, at the top-right, click Close.

 

12. In the Objects table click the cloudacademy-logo.png object:

alt

 

13. Scroll down to the Metadata section and observe the key-value pairs you added:

alt

This is also where you can add, remove, and edit metadata after you have uploaded objects to Amazon S3.

 

Summary

In this lab step, you added custom system and user metadata to an object in your S3 bucket.

Custom metadata can be useful. For example, your application could search a specific folder in your S3 bucket for all PNG images that are not "current" (based on custom user metadata), and generate a notification stating there are images that need to be updated.

Learning Pathnavigation