Skip to content

Instantly share code, notes, and snippets.

@andreburto
Created March 8, 2021 16:58
Show Gist options
  • Save andreburto/14677f35994b2a83d9850523e27688e0 to your computer and use it in GitHub Desktop.
Save andreburto/14677f35994b2a83d9850523e27688e0 to your computer and use it in GitHub Desktop.
Node.js script to upload images to an S3 bucket.
const fs = require("fs")
const AWS = require('aws-sdk');
const bucketPath
const main = (imgPath) => {
fs.stat(imgPath, function(err, stats) {
if (!stats.isDirectory()) {
throw new Error(`"${imgPath}" is not a directory.`)
}
})
fs.readdir(imgPath, (err, files) => {
files.forEach(file => {
console.log(file);
});
});
}
main(process.env.IMGPATH)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment