Skip to content

Instantly share code, notes, and snippets.

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