HTML uploaded to s3 through PutObjectCommand upload with a content-type of "application/octet-stream" instead of "text/html" #5530
Closed
rajeshrah22
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Even after specifying the contentType in the PutObjectCommand input, the HTML file is still uploaded with Content-Type "application/octet-stream".
Here is the request code:
`const uploadFile = async (filePath,bucketName,keyName, type="text/html") => {
// Read the file
const file = fs.readFileSync(filePath)
// Setting up S3 upload parameters
const uploadParams = {
Bucket: bucketName, // Bucket into which you want to upload file
Key: keyName, // Name by which you want to save it
Body: file, // Local file
contentType: type
}
console.log(uploadParams)
const command = new PutObjectCommand(uploadParams)
try {
const response = await client.send(command)
console.log(response)
} catch (err) {
console.error(err)
}
}`
Here is the command inputs logged in the console:
Here is the information in the console:
Here is the curl request to the bucket's static website link:
Any knowledge of this would be appreciated.
Beta Was this translation helpful? Give feedback.
All reactions