How do you upload a directory using the javascript SDK

0

I'm trying to upload a directory that contains subdirectories and files to an S3 bucket. I'm using the javascript SDK. It's what my company uses, I cannot use another language. This functionality is supported in .Net and Java. I cannot locate any guide for this in javascript. I'm wondering if it's supported. If it's not what's the best way around this, will this ever get supported?

asked a year ago441 views
2 Answers
1

Have you tried using the JS example listed here? https://docs.aws.amazon.com/AmazonS3/latest/userguide/example_s3_PutObject_section.html.

  • for each file in the directory
  • get the full path of the file
  • Upload with the prefix

You can also try https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/sync.html.

profile pictureAWS
EXPERT
answered a year ago
  • The CLI command is the closest usable option so far. Thanks for calling attention to it. I need to be able to call the upload programmatically after a folder has been created. If using node child_process to call the sync through a Bash command is acceptable to my company then this might be the solution.

0

Try giving this a go. Recursively iterating through the directories and files in JavaScript.

Here you can find an example code snippet demonstrating the recursive directory upload process using the AWS SDK for JavaScript modules workaround [ 1 ].

References:

[ 1 ] https://docs.aws.amazon.com/AmazonS3/latest/userguide/example_s3_UploadDirectoryToBucket_section.html

answered a year ago
  • The example you provided was for the Java SDK (I linked it in the original question) So this will not work for javascript/typescript.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions