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

前端 未结 5 619
悲哀的现实
悲哀的现实 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:18

    It seems that

    When uploading files, the AWS S3 Java client will attempt to determine the correct content type if one hasn't been set yet. Users are responsible for ensuring a suitable content type is set when uploading streams. If no content type is provided and cannot be determined by the filename, the default content type, "application/octet-stream", will be used.

    Giving the file a .html extension provides a way to set the correct type.

    According to the examples I've been looking at, the code you show should be doing what you want to do. :/

提交回复
热议问题