2

I am trying to upload csv file by aws-sdk/lib-storage

When I specify S3 url(ex. https://s3.us-east-1.amazonaws.com/aaa/bbb/ccc/ddd/eee) to Bucket property of params, error massage InvalidBucketName: Bucket name shouldn't contain '/' occurred.

How can I specify url containing '/'?

・code

      const parallelUploads3 = new Upload({
        client: new S3Client({
          region: 'us-east-1',
          credentials
        }),
        params: {
          Bucket:
            'https://s3.us-east-1.amazonaws.com/aaa/bbb/ccc/ddd/eee,
          Key: file.name,
          Body: file
        },
        leavePartsOnError: false
      })

When I specify only Bucket Name, no containing '/', upload was succeeded.

0

1 Answer 1

0

In the 'Bucket' parameter just give the bucket name and in the 'Key' give the path and file name. And also you don't need to give 'https://s3.us-east-1.amazonaws.com/' in the 'Bucket' parameter. So, your code would be like this:

const parallelUploads3 = new Upload({
        client: new S3Client({
          region: 'us-east-1',
          credentials
        }),
        params: {
          Bucket: <Bucket Name>,
          Key: <File Path>/file.name,
          Body: file
        },
        leavePartsOnError: false
      })
Sign up to request clarification or add additional context in comments.

1 Comment

I appreciate your answer!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.