Created
March 8, 2021 16:58
-
-
Save andreburto/14677f35994b2a83d9850523e27688e0 to your computer and use it in GitHub Desktop.
Node.js script to upload images to an S3 bucket.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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