-2

If I am uploading a pdf file in the S3 bucket using SDK. Do I also need to include the suffix “.pdf” in the key.

PutObjectRequest.builder() .bucket(bucketName) .key(key)

Is “myName” a valid key in this case or I need to use “myName.pdf” as key.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
Demo Me
  • 13
  • 1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Oct 03 '22 at 19:09

1 Answers1

2

The key is the full filename, including the path.

Examples:

  • myName.pdf
  • my-folder/myName.pdf
  • folder1/folder2/very-important-file.pdf

You do not need to include extension -- the choice of Key is up to you!

You might also want to specify the Content-Type so that browsers know how to open the file when it is downloaded. See: Why does file uploaded to S3 have content type application/octet-stream unless I name the file .html?

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470