aroooo
aroooo

Reputation: 5056

Rest API: Amazon S3 Best Practices

I have a REST API and I'm using S3 to store images .zip files, and other media like video. Is it common practice to use a single bucket for everything? Or divide buckets by file type?

For example, here are some of the kinds of content I have:

.jpg
.png
.zip
.mov
.maya
.obj

Upvotes: 1

Views: 213

Answers (2)

Stefan Bobev
Stefan Bobev

Reputation: 171

You can store all your files in a single bucket without a problem. If you wish to have more separation, keys in S3 are composite similar to URLs. For example you can have:

<your_bucket_name>/images/<key1>.png
<your_bucket_name>/images/<key2>.jpg
<your_bucket_name>/videos/<key3>.mp4

This will keep all your files in a single bucket, but in the AWS console they will be split similar to a file system - inside folders. Note that in order to access the resource stored in S3 you will need to use the full path e.g /images/key1.png

Upvotes: 2

John Rotenstein
John Rotenstein

Reputation: 269312

A single Amazon S3 bucket can contain any number of objects.

Reasons for using separate buckets are typically:

  • Desire for creating a bucket in a different region
  • Separation of duties (eg keep HR information separate)
  • Separation of purpose (eg keep test files separate to Production files)
  • Separation of systems (eg Inventory system vs Customer Service system)

There is no reason to use a different bucket for different file types, unless those file types are used for different purposes (like the above).

Upvotes: 4

Related Questions