Home > Enterprise >  Does S3 Bucket Key name require file extension?
Does S3 Bucket Key name require file extension?

Time:10-04

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.

CodePudding user response:

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?

  • Related