scp -i ~/Downloads/file.pem local_image_file user@ec2_elastic_ip:/home/user/images/
var AWS = require('aws-sdk');
AWS.config.update({accessKeyId: "ACCESS_KEY",secretAccessKey: 'SECRET_KEY'});
var s3bucket = new AWS.S3({params: {Bucket: 'BUCKET_NAME'}});
function uploadFileOnS3(fileName, fileData){
var params = {
Key: fileName,
Body: fileData,
};
s3bucket.upload(params, function (err, res) {
if(err)
console.log("Error in uploading file on s3 due to "+ err)
else
console.log("File successfully uploaded.")
});
}
# easy way
import boto3
s3 = boto3.resource(
service_name='s3',
region_name='Your region',
aws_access_key_id='Your id',
aws_secret_access_key="Your Key")
bucket = s3.Bucket('your bucket name')
bucket.upload_file(Filename='temp.csv', Key='temp.csv')
# file path __________↑ ↑
# (which you want to upload) |
# |______path (where you want to upload inside bucket)
aws s3 cp /css/ s3://yourbucketname/css/ --recursive