Application Octet Stream File
- Application/octet-stream Php File Upload
- Application Octet Stream Pdf
- Application/octet-stream File Types
Octet-stream does not refer to a specific type of file - it could be anything from a spreadsheet to an executable program. To open an unidentified file, you need to either figure out which program can open the file as a document or change the file's extension to run as a program. When attached to an email, save the octet-stream before opening it. A Multi-Purpose Internet Mail Extension (eg. “application/octet-stream”), also known as a MIME, is type of Internet standard originally developed to allow the exchange of different types of data files through e.
The HTTP standard says:
If this header [Content-Disposition: attachment] is used in a response with the application/octet-stream content-type, the implied suggestion is that the user agent should not display the response, but directly enter a `save response as..' dialog. Linux ubuntu 12.04 download for usb.
I read that as
But I would have thought that Content-Type
would be application/pdf
, image/png
, etc.
Should I have Content-Type: application/octet-stream
if I want browsers to download the file?
1 Answer
No.
The content-type should be whatever it is known to be, if you know it. application/octet-stream
is defined as 'arbitrary binary data' in RFC 2046, and there's a definite overlap here of it being appropriate for entities whose sole intended purpose is to be saved to disk, and from that point on be outside of anything 'webby'. Or to look at it from another direction; the only thing one can safely do with application/octet-stream is to save it to file and hope someone else knows what it's for.
You can combine the use of Content-Disposition
with other content-types, such as image/png
or even text/html
to indicate you want saving rather than display. It used to be the case that some browsers would ignore it in the case of text/html
but I think this was some long time ago at this point (and I'm going to bed soon so I'm not going to start testing a whole bunch of browsers right now; maybe later).
RFC 2616 also mentions the possibility of extension tokens, and these days most browsers recognise inline
to mean you do want the entity displayed if possible (that is, if it's a type the browser knows how to display, otherwise it's got no choice in the matter). This is of course the default behaviour anyway, but it means that you can include the filename
part of the header, which browsers will use (perhaps with some adjustment so file-extensions match local system norms for the content-type in question, perhaps not) as the suggestion if the user tries to save.
Hence:
Means 'I don't know what the hell this is. Please save it as a file, preferably named picture.png'.
But fair warning: beware the Mind Flayer.Download the Windows 1.11 app today.
Means 'This is a PNG image. Please save it as a file, preferably named picture.png'.
Means 'This is a PNG image. Please display it unless you don't know how to display PNG images. Otherwise, or if the user chooses to save it, we recommend the name picture.png for the file you save it as'.
Of those browsers that recognise inline
some would always use it, while others would use it if the user had selected 'save link as' but not if they'd selected 'save' while viewing (or at least IE used to be like that, it may have changed some years ago).
protected by Rachel GallenMar 15 at 8:50
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
Not the answer you're looking for? Browse other questions tagged httpbrowserhttp-headersdownload or ask your own question.
I am trying to download a file using data uri in following manner:
The problem is that the downloaded file is always named 'Unknown', whatever I try to use as filename. Is this the correct way to give the file a name ? or something else needs to bedone ?
Ashraf Bashir5 Answers
Here's the solution, you just have to add a download
attribute to anchor taga
with desired name
Another solution is to use JQuery/Javascript
Ashraf BashirAshraf BashirOn Safari, you might want to use this, and instruct the user to ⌘-S the file:
Otherwise, this uses Filesaver.js, but works ok:
Note: There is some AngularJS in the code above, but it should be easy to factor out..
Application/octet-stream Php File Upload
For those that are using other libraries like angularjs or backbone, you can try something like this.
$('a.download').attr('href', 'data:application/csv;charset=utf-8,'+$scope.data);
RickRickI had the same issue and finally I solved in all browsers serving the CSV file in the server-side:
Aral RocaAral RocaFor anybody looking for a client-side solution using Javascript only, here is mine, working on any browser except IE 10 and lower (and Edge..why?!):