Upload to and delete files from Amazon Web Service S3 with nodejs. In AWS, I'm using IAM which supplies basic security. It is setup so users only have permission to read, add (put), or delete objects from a bucket. Images are public, but the bucket isn't.
I'm using React for the front end.
You will need to have an sufficient version of node.js and npm (or yarn).
You can use postman to test the HTTP requests.
Choose a directory and create your react app.
$ create-react-app <app-name>
- aws-sdk
- multer
- multerS3
- dotenv
- superagent
- axios
- react-dropzone
- massive (for postgreSQL) (optional)
$ npm install aws-sdk multer multer-s3 dotenv superagent axios react-dropzone massive
We also need express, but that's already installed with create-react-app. Also massive is not necessary. I just used it to store the link to the file in S3 to my database. It isn't necessary for understanding how to upload and delete from S3.
We're going to start with the backend since it's the most important part of this demo, so let's start by setting up the sever.
In the root folder create a new folder named server, and in that folder create a new file named index.js
/app-name
/node_modules
/public
/server
index.js
/src
package.json
README.md
...README in progess