我的程序特定的二进制文件应使用哪种 MIME 类型?
我的程序使用它自己的二进制文件类型,所以我假设我不能使用 MIME 类型文本/纯文本,因为它不是 7 位 ASCII 文件。
我应该将其称为“application/myappname”吗?
My program uses its own binary file type, so I assume I can't use MIME type text/plain, as it is not a 7-bit ASCII file.
Should I just call it "application/myappname"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我推荐
application/octet-stream
因为 RFC2046 说“The ” “八位字节流”子类型用于指示主体包含任意二进制数据”和“对于接收“应用程序/八位字节流”实体的实现的建议操作是简单地将数据放入 文件[...]”。我认为这样你就能更好地处理任意程序,这些程序在遇到你未知的 mime 类型时可能会呕吐。
I'd recommend
application/octet-stream
as RFC2046 says "The "octet-stream" subtype is used to indicate that a body contains arbitrary binary data" and "The recommended action for an implementation that receives an "application/octet-stream" entity is to simply offer to put the data in a file[...]".I think that way you will get better handling from arbitrary programs, that might barf when encountering your unknown mime type.
你也许可以使用:
application/x-binary
什么是 MIME 类型
mime 类型列表
查看说明
you could perhaps use:
application/x-binary
what is MIME types
list of mime types
see explanation
mimetype 标头被浏览器识别,以便(快速)可能识别处理程序以使用下载的文件作为目标,例如,将下载 PDF,并使用 PDF 文件的路径执行您的 Adobe Reader 程序一个论点,
如果您需要编写一个浏览器扩展来通过操作系统处理下载的文件,或者您只是想让您的项目看起来更“专业”,请继续选择一个独特的 mimetype 供您使用,
如果
您想确保将下载文件看看这个答案:https://stackoverflow.com/a/34758866/257319
如果你想让你的文件类型特别有条理,可能值得在文件的前几个字节中添加一些字母,例如,每个 JPG 在其文件开头都有这样的内容:
如果您能承受 4 或 8 个字节的跳转,那么它可能对您在 剩下的事情
:)
mimetype headers are recognised by the browser for the purpose of a (fast) possible identifying a handler to use the downloaded file as target, for example, PDF would be downloaded and your Adobe Reader program would be executed with the path of the PDF file as an argument,
If your needs are to write a browser extension to handle your downloaded file, through your operation-system, or you simply want to make you project a more 'professional looking' go ahead and select a unique mimetype for you to use,
it would make no difference since the operation-system would have no handle to open it with (some browsers has few bundled-plugins, for example new Google Chrome versions has a built-in PDF-reader),
if you want to make sure the file would be downloaded have a look at this answer: https://stackoverflow.com/a/34758866/257319
if you want to make your file type especially organised, it might be worth adding a few letters in the first few bytes of the file, for example, every JPG has this at it's file start:
if you can afford a jump of 4 or 8 bytes it could be very helpful for you in the rest of the way
:)
根据规范RFC 2045 #Content-Type 标头字段的语法
application/myappname
是不允许的,但application/x-myappname
是允许的,对我来说听起来最适合您的应用程序。According to the specification RFC 2045 #Syntax of the Content-Type Header Field
application/myappname
is not allowed, butapplication/x-myappname
is allowed and sounds most appropriate for your application to me.