Hello guys,

In this blog, we will discuss how to upload an image to Amazon s3 bucket. Amazon s3 provide online storage service. In the Amazon s3 data stored in the bucket. A bucket is just like a folder which contains your data for this we have to create an Amazon web services account ( on https://aws.amazon.com/s3/ )and get an access key Id, secret access key.

Now we have to install Amazon SDK node module.

And create a JSON file (aws_config.json) in your project directory that AWS access key id, secret key id, and region.

Now require aws-sdk module and load aws_config.json file.

create an instance s3 and create a bucket in s3 which contain an image of your project.

upload image to s3 bucket :

In ASW s3 bucket image stored with a key. To manage permission and access of AWS s3 bucket with the help of ACL(Access control list).ACL grant permission to the bucket.AWS provides predefined grantees and permission which is called  Canned ACL.

ACL:public-read means the owner has full access and other users only read access.

To upload an image in the bucket with a key and body argument takes an image in the byte stream.

get an image from the s3 bucket:

To get URL of upload image the getSingedUrl method return signed URL of an object which is expired after a limited time.