299

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"?

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
Powerbook165c
  • 2,999
  • 2
  • 15
  • 3

4 Answers4

455

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.

user786653
  • 29,780
  • 4
  • 43
  • 53
  • 2
    This is a very appropriate type whenever you have only *one* binary type in your application. If you have multiple *different* formats you still need to use something list `application/x.`, `application/vnd.` or `application/prs.`. `application/octet-stream` only has the `TYPE` argument which is not intended for machine use. See https://datatracker.ietf.org/doc/html/rfc2046#section-4.5.1 – exhuma May 27 '21 at 12:09
19

you could perhaps use:

application/x-binary

what is MIME types

list of mime types

see explanation

serup
  • 3,676
  • 2
  • 30
  • 34
  • 6
    Why not use the [standardized `application/octet-stream`](https://www.iana.org/assignments/media-types/application/octet-stream) instead? `x-binary` is not [IANA standardized](https://www.iana.org/assignments/media-types/media-types.xhtml#application). Consuming programs may interpret it as binary anyway because they do not know that mime type. But it is not a guarantee. And we do have an explicit mime type for it. – Kissaki Feb 02 '21 at 16:37
  • `application/x-binary` does not follow the naming scheme laid out in [RFC-6838](https://datatracker.ietf.org/doc/html/rfc6838#section-3) and should therefore be avoided. Changing it to `application/x.binary` would be better but is still discouraged by the RFC. A better choice would be `application/prs.binary` or `application/vnd.binary`, but in the latter case you'd be required to register it with IANA. – exhuma May 27 '21 at 12:13
6

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

:)

Community
  • 1
  • 1
6

According to the specification RFC 2045 #Syntax of the Content-Type Header Field application/myappname is not allowed, but application/x-myappname is allowed and sounds most appropriate for your application to me.

Community
  • 1
  • 1
Nate
  • 12,963
  • 4
  • 59
  • 80