I'm using the node-s3-client library to upload files to my bucket.
I have a local folder, /build, that I would like to upload to a folder within an S3 bucket, entitled Library.
Placing individual files into the Library folder is easy:
const params = {
localFile: './individualFile',
s3Params: {
Bucket: config.aws.s3Bucket,
Key: 'Library/individualFile',
}
}
const uploader = client.uploadFile(params); // works great!
However, I'm not sure how to configure the params to upload the contents of a directory into a folder within a bucket. I've tried this:
const params = {
localDir: './build',
s3Params: {
Bucket: config.aws.s3Bucket,
Key: 'Library/',
}
}
const uploader = client.uploadDir(params); // doesn't work :(
The upload is successful, but the contents end up at the root of the bucket rather than inside the folder. In other words, the Key feature doesn't seem to work when it comes to directories.
Key?