A Node.js application which creates an S3 bucket and uploads a file with permissions and metadata.
This example uses the createBucket
and upload
methods of the AWS SDK for JavaScript.
See API doocumentation for detailed information; https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html
To see the available parameters for the s3 upload
method, see the paramObjects.js
file.
- An AWS account with appropriate permissions to create the required resources
- Node.js (v12+) and npm (v6+) installed and configured for use with AWS
- Bash environment in which to execute the scripts
- A jpg file in the executing directory called
koala.jpg
The code can be executed as follows:
node s3PutObject.js
sudo apt-get install unzip
wget https://github.com/abilous-ti/aws-s3-nodejs-demo/archive/refs/heads/main.zip
unzip main.zip
cd aws-s3-nodejs-demo-main/
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
npm install
node s3PutObject.js