Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save maskaravivek/5831a1c2b0c09d2951ed734c154a10a4 to your computer and use it in GitHub Desktop.
Save maskaravivek/5831a1c2b0c09d2951ed734c154a10a4 to your computer and use it in GitHub Desktop.
const s3 = require('./config');
const bucketName = 'my-unique-bucket-name';
const filePath = './path/to/file.jpg';
const fileContent = fs.readFileSync(filePath);
const params = {
Bucket: bucketName,
Key: 'file.jpg',
Body: fileContent
};
s3.upload(params, (error, data) => {
if (error) {
console.error(error);
} else {
console.log('File uploaded successfully!');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment