DEV Community

Cover image for Creating and Uploading files to AWS S3 bucket.
emmilly immaculate
emmilly immaculate

Posted on

Creating and Uploading files to AWS S3 bucket.

AWS S3 bucket is one of the numerous services that Amazon Web Services offers in the cloud.
Its chiefly centered on providing storage space.Ideally anyone with an AWS account can just create a bucket and simply upload their files(objects) into the bucket.

By default, all object(files) are inaccessible to the public until the owner explicitly defines a policy(rule) to make them public.

In this article, we shall spin up an s3 bucket and upload our files it then obtain a link to access them.

Step 1: Search for s3 service once logged in.

Seach s3 bucket
Step 2: In the s3 dashboard, look for the orange button "Create bucket".

Create button

Step 3: Fill in the bucket name.
Note:the bucket name has to be unique from all other bucket names on aws.e.g bucket3857590.

bucket name

Step 4: Leave everything else as default and click the orange "create" button at the bottom.

create item

We shall see a success message that our bucket has been created and is available in the list of buckets probably at the bottom of the list.

Success bucket creation

Step 5: Next, we shall upload a simple file to the bucket.First we click on the bucket we created.And click upload.

upload file

Step 6: We will be presented with 3 options to upload.

  • upload a file

  • upload a folder

  • drug and drop

For this case i will choose a simple file, so i will either drug and drop it or click the add file button.

Step 7: Once the file is uploaded, click the "upload" button.

upload button
We should see a success message and be able to access a link to the uploaded file.

success upload

Step 8: Now if we click the bucket and try to click on the link to the file we get an access denied page.This is because by default , all items are by default

bucket page

Inaccessible

Access denied page

Step 9: Next, we shall create a policy to make the link accessible.

  • First, we need got to the bucket permissions.

Bucket permissions

  • Next, we shall click the edit button.

Edit button on Block access

  • Then, we shall can uncheck the block all public access.

Uncheck block all access

  • Click confirm.

confirm

  • Next, we shall edit the Object Ownership permissions to use Access Control Lists.Click the "Edit" button.

 edit object ownership

  • Then, we can now enable ACls and tick checkbox "I acknowledge that ACLs will be restored".

Enable ACLs

Step 10: Now let us make the file public.Under the file page,hover to the top right corner of the file on the object actions dropdown and choose "Make Public".

make file public

  • click the Make Public button.

 make public button

  • You should success message.

success make file public

Now if we sheck the object/file url again , it should be accessible.

check object/file URL

Note that this way od making objects public can be quite hectic to do for each item.So it combert this, we can use policies to set access rights on the files and the bucket.

Till Next time.

Top comments (0)