how to upload file to s3 nodejs
const fs = require('fs');
const AWS = require('aws-sdk');
const s3 = new AWS.S3({
accessKeyId: process.env.AWS_ACCESS_KEY,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
});
const fileName = 'contacts.csv';
const uploadFile = () => {
fs.readFile(fileName, (err, data) => {
if (err) throw err;
const params = {
Bucket: 'testBucket', // pass your bucket name
Key: 'contacts.csv', // file will be saved as testBucket/contacts.csv
Body: JSON.stringify(data, null, 2)
};
s3.upload(params, function(s3Err, data) {
if (s3Err) throw s3Err
console.log(`File uploaded successfully at ${data.Location}`)
});
});
};
uploadFile();
Also in JavaScript:
- jquery get base url
- Validate a gregorian date
- component unmount useeffect
- jquery toggle function
- js check if function is a constructor
- dayjs invalid date
- js arrotondare superiore numero
- js remove property from object
- compare arrays javascript
- js background image
- insert json into sql
- vscode new file shortcut
- first repeated character in a string javascript
- how to verify json format is valid
- iterate object javascript
- js isset
- get width of a dom element js
- find if json property is of type date type
- extendscript unzip file
- ellipses in js
- get an element from outside of iframe jquery
- get the last element of array javascript
- unban command discord.js v12
- twitch