Why does file uploaded to S3 have content type application/octet-stream unless i name the file .html

前端 未结 5 615
悲哀的现实
悲哀的现实 2021-01-17 09:04

Even though I set content type to text/html it ends up as application/octet-stream on S3.

ByteArrayInputStream contentsAsStream = new ByteArrayInputStream(c         


        
5条回答
  •  醉话见心
    2021-01-17 09:24

    I could fix this issue easily by commandline, I faced similar issue while uploading html files through aws commandline even though the file name had correct extension.

    As mentioned in earlier comments, adding --content-type param fixes the issue. Executing below command and refreshing page returned octet stream.

    aws s3api put-object --bucket [BUCKETNAME] --body index.html  --key index.html     --profile [PROFILE] --acl public-read 
    

    Fix: add --content type text/html

    aws s3api put-object --bucket [BUCKETNAME] --body index.html  --key index.html  --profile [PROFILE] --acl public-read --content-type text/html
    

提交回复
热议问题