Application Octet Stream Charset Binary
I have a couple of C source files (one.cpp and one.h) that are being reported as type data by the file command in Linux. When I run the file -bi command against these files, I'm given this output (same output for each file): application/octet-stream; charset=binary Each file is clearly plain-text (I can view them in vi). What's causing file to misreport the type of these files? Could it be some sort of Unicode thing? Both of these files were created in Windows-land (using Visual Studio 2005), but they're being compiled in Linux (it's a cross-platform application). Any ideas would be appreciated.
How Can I Open 'Octet-Stream'? By: Aaron Parson. If it doesn't, quit the program and try again with another application. Double-click the file again, once you find a working application. Check the box to 'Use this app' for all similar files and pick the correct program. This associates the extension with the selected application for. I have a file with.bck extension and file -i returns this: application/octet-stream; charset=binary I don't know where this file came from but someone asked.
Update: I don't see any null characters in either file. I found some extended characters in the.cpp file (in a comment block), removed them, but file still reports the same encoding. I've tried forcing the encoding in SlickEdit, but that didn't seem to have an effect. When I open the file in vim, I see a converted line as soon as I open the file.
Perhaps I can get vim to force the encoding? Vim tries very hard to make sense of whatever you throw at it without complaining.
This makes it a relatively poor tool to use to diagnose file's output. Vim's 'converted' notice indicates there was something in the file that vim wouldn't expect to see in the text encoding suggested by your locale settings (LANG etc). Others have already suggested.
cat -v. xxd You could try grepping for non-ASCII characters.
grep -P ' x7f- xff' filename The other possibility is non-standard line-endings for the platform (i.e. CRLF or CR) but I'd expect file to cope with that and report 'DOS text file' or similar.
The 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.' I read that as Content-Type: application/octet-stream Content-Disposition: attachment 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? 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'.
File Type Application Octet Stream
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: Content-Type: application/octet-stream Content-Disposition: attachment; filename='picture.png' Means 'I don't know what the hell this is. Please save it as a file, preferably named picture.png'.
Content-Type: image/png Content-Disposition: attachment; filename='picture.png' Means 'This is a PNG image. Please save it as a file, preferably named picture.png'. Content-Type: image/png Content-Disposition: inline; filename='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). This was a great answer, and it would really be nice if things worked like that. But unfortunately all browsers are mostly broken. For instance, Google Chrome will not open a 'file save' window for you if this is your response from a form, regardless of including 'Content-Disposition: attachment', even with 'application/octet-stream' as the content-type. And then they print a message saying you may be under attack. There is just no way of it letting me save a file.
Application Octet Stream Javascript
You have to configure xdg-open even if you just want to save a file. I'm sick of this. – Apr 4 '15 at 17:44.