svg - 用于将 svg 图像上传到 AWS S3 的内容类型

标签 svg amazon-web-services amazon-s3 mime-types content-type

我试图在不指定任何内容类型的情况下将 *.svg 图像上传到 S3。此上传成功,AWS 默认将 Content-Type 设置为 binary/octet-stream。现在,当我尝试在浏览器中使用图像的 S3 url 时,浏览器不会呈现图像并抛出不正确的 MIME 类型警告。

为了设置正确的 mime-type,我检查了 AWS 提供的 Content-type 列表,但它没有“image/svg+xml”。

所以我想知道是否有人尝试将 svg 图像上传到 S3?在这种情况下设置的内容类型是什么?或者是否有任何其他兼容的 Content-type 可用于将 svg 图像上传到 S3?

提前致谢。

最佳答案

正如您所提到的,SVG 文件的正确 Content-Type 是“image/svg+xml”。

即使 AWS 控制台没有在 Content-Type 选择字段中提供该值,您仍然可以输入它并且 S3 会接受它。

AWS 在其 API 文档中为 Content-Type header 指定了以下内容:

A standard MIME type describing the format of the contents. For more information, go to http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17.

Type: String

Default: binary/octet-stream

Valid Values: MIME types

Constraints: None



有关更多详细信息,请参阅 http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPUT.html

关于svg - 用于将 svg 图像上传到 AWS S3 的内容类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18009493/

相关文章:

javascript - 通过 dblclick 事件获取 svg 的文本元素

javascript - d3 Sankey - 是否有可能影响或决定节点的位置?

amazon-web-services - AWS 上用于 SNS 通知的多区域架构

amazon-web-services - 是什么原因导致错误 "Unable to find the private GraphQL API for this domain."?

java - AWS S3 getObject() 导致 HTTP 连接超时

javascript - 将复杂的 SVG 文件与 paper.js 结合起来

jquery - 打印 getOrgChart

ios - Azure、AWS、同步服务、数据库和 iOS

amazon-web-services - 通过 Cloudformation-Update 堆栈修改 EC2 上的文件

amazon-s3 - 如何使用 IAM 服务动态创建 Airflow S3 连接