Skip to content

Instantly share code, notes, and snippets.

@mako34
Created July 18, 2018 07:40
Show Gist options
  • Save mako34/25c926553dae10209e6766e079fccbc2 to your computer and use it in GitHub Desktop.
Save mako34/25c926553dae10209e6766e079fccbc2 to your computer and use it in GitHub Desktop.
node S3 upload
const fs = require('fs');
const AWS = require('aws-sdk');
const s3 = new AWS.S3({
accessKeyId: 'aaa',
secretAccessKey: 'bbb+oeyjn8zGANuDyCIY',
region: 'ap-southeast-2'
// accessKeyId: process.env.AWS_ACCESS_KEY,
// secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
});
const fileName = 'su.csv';
const uploadFile = () => {
fs.readFile(fileName, (err, data) => {
if (err) throw err;
const params = {
Bucket: 'sb-communicate-files-dev',
Key: 'su.csv',
Body: data
};
s3.upload(params, function(s3Err, data) {
if (s3Err) throw s3Err
console.log(`File uploaded successfully at ${data.Location}`)
});
});
};
uploadFile();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment