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?

gefragt vor einem Jahr468 Aufrufe
2 Antworten
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
EXPERTE
beantwortet vor einem Jahr
  • 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

beantwortet vor einem Jahr
  • The example you provided was for the Java SDK (I linked it in the original question) So this will not work for javascript/typescript.

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen