Search code examples
httphttp-headersmime-typesbasic

What MIME type should I send with a legacy DOS image type that must be saved and not displayed?


I need to allow my users to download BSAVE "images" from my webserver. BASVE "image" files are a raw dump of a segment of RAM which contains screen data mostly used in BASIC programming. No browser can display this image, rather it is "displayed" by BLOADing it back into RAM.

I don't believe application/octet-stream is correct because it isn't an executable but sending any image/* MIME type would be inaccurate and confusing. Sending the file as text would be inaccurate and confusing as well.

Which MIME type will allow the download/save of the file while being the most accurate descriptor of the file and its contents? Is application/octet-stream the most possibly correct wrong answer?


Solution

  • application/octet-stream can be (and usually is) used for any raw data, it is not just for executables (which would normally be application/x-msdos-program, application/x-msdownload, application/vnd.microsoft.portable-executable, etc instead). Its name literally says it is a "stream of octets" (aka bytes). The application/... portion of the name does not refer to executable applications, it actually means that the data is meant to be typically consumed by applications.

    You should also include a Content-Disposition: attachment; filename="..." response header to indicate to the client that the data should be saved to a file instead of displayed in the browser.

    Content-Type: application/octet-stream
    Content-Disposition: attachment; filename="image.bsave"