This project provides a simple interface to upload files to an AWS S3 bucket using Node.js. Created to go alone with this guide.
- Node.js installed on your machine
- An AWS account with access to S3
- AWS credentials (Access Key ID and Secret Access Key)
- An Evervault account (create a free account here)
git clone https://github.com/Eclairemoy/uploadtos3.git
cd uploadtos3/srcEnsure you're in the src directory and run:
npm installCreate a .env file in the src directory with the following content:
AWS_ACCESS_KEY_ID=your_access_key_id
AWS_SECRET_ACCESS_KEY=your_secret_access_key
AWS_REGION=your_aws_region
S3_BUCKET_NAME=your_s3_bucket_nameReplace your_access_key_id, your_secret_access_key, your_aws_region, and your_s3_bucket_name with your actual AWS credentials and desired S3 bucket information.
Place a sample file you wish to upload in the src directory. For example, sample.txt.
Execute the upload script using Node.js:(Stack Overflow)
node upload.js sample.txtThis command will upload sample.txt to the specified S3 bucket.
- Ensure your AWS credentials have the necessary permissions to upload files to the specified S3 bucket.
- The script assumes the file to upload is located in the same directory (
src). - You can modify the script to handle different directories or multiple files as needed.
For more details and advanced configurations, refer to the AWS SDK for JavaScript Documentation.