In this article, we will check how we can connect the Amazon S3 bucket with strapi.
Amazon S3 is an abbreviation of Amazon Simple Storage Service. It is used to store and retrieve any amount of data. It stores data in the form of objects.
How to work with Amazon S3 Buckets.
Buckets are used to upload data to Amazon S3 and for that, you have to create a bucket. Bucket’s name should be globally unique. I will not discuss S3 buckets here in detail as it is totally out of the scope for this topic.
How to create Amazon S3 Bucket
First, you need to create a bucket in order to store your data.
- Login to your AWS Management Console
- Under the Storage category, click on S3
- From S3 Management Console click on Create Bucket button.
- In the next pop up enter the Bucket name, Region and press next.
- Leave the configuration options as it is.
- Now in the Set permissions tab, uncheck all the checkboxes to allow public access to this bucket.
- Click next and then click Create bucket.
That’s it, now you have successfully created a bucket with public access.
Now let’s configure strapi.
File upload and connect S3 bucket with strapi.
Strapi has a default upload plugin that helps to upload any kind of files on the server or any external provider like Amazon S3.
This plugin uses a single route POST/upload to upload single or multiple products together.
Let’s install the AWS S3 provider.
To install run this command.
npm install strapi-provider-upload-aws-s3@beta–save
Now run your strapi project using this command. You can check my this article to install and create a project in strapi.
Now head towards http://localhost:1337/admin and click on Plugins.
In the next screen click on the gear icon on the right side parallel to the FILES UPLOAD.
Let’s proceed with Development, now in providers select Amazon Web Service S3. You also have to provide the Access API, Secret Access Token, Region and Bucket name.
To access these APIs navigate to your profile drop-down and click on My Security Credentials. From pop up, click on Continue to Security Credentials and then open Access Keys Tab from there click on Create New Access Key. Now download your key’s file and keep them in a safe place.
Now from the file get your Access API and Secret Access Token. Select the Region from the drop-down and enter bucket name.
Once these settings are done hit the Save button. Now you have successfully configured and connected S3 Bucket with your strapi project.
Go ahead and upload a file to test this, once uploaded navigate to your S3 bucket and you will see a file uploaded there.
In the next article, we will check how we can connect our strapi project with MongoDB and MongoDB Atlas
To enhance your knowledge regarding advanced technologies, tune to Morosoft tweaks . If you want to be up to date with all that is happening in the world, Morosoft Tweaks is providing you all under one roof. We also aim to provide relevant information in a quick and sophisticated manner. Contact us: email@example.com