Creating and Uploading files to AWS S3 bucket.
Published: 2023-04-07 08:12:19

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d84wwkh6b2zv96eu00gh.png)
Step 2: In the s3 dashboard, look for the orange button "Create bucket".

![Create button](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zurimxizct4jpg1zzhzc.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8kfmxrswrcxttfppzscg.png)

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

![create item](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3k1vdi9d74r8uufe5l4u.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m9q1sp0o8eqmlqo6422m.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j8l41r3tl97ug90bqro5.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8bh5qwwbymbe89wt7lyf.png)
We should see a success message and be able to access a link to the uploaded file.

![success upload](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lo7ryqzjxl3q16n1amm1.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/exdkf254oumzbx6wj7ln.png)

Inaccessible

![Access denied page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ybygncd84548z1nyzgz9.png)

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

- First, we need got to the bucket permissions.


![Bucket permissions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ceuc3jqf9i4ruhtwcuof.png)

- Next, we shall click the edit button.

![Edit button on Block access ](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/glpxp88i25u5rogp1elm.png)

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

![Uncheck block all access](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k6fedxp38cxibs2bh1u1.png)

- Click confirm.

![confirm ](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/taxxynuo53f6op7pq1vu.png)

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

![ edit object ownership](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uosminjgkfiho59hrho8.png)

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

![Enable ACLs](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/roh483u304ji8lctuw91.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s9lw9xctmbe70zh6vkeb.png)

- click the Make Public button.

![ make public button](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vt62j040rl652c66ymt3.png)

- You should success message.

![success make file public](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9zqbq16dwi3t9lgjx3i3.png)

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

![check object/file URL](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vkb0f22fmjuxq3r52wgs.png)

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.