by admin

What Is An Octet Stream

Did your computer fail to open an OCTET-STREAM file? We explain what OCTET-STREAM files are and recommend software that we know can open or convert your OCTET-STREAM files.

What is an OCTET-STREAM file?

The OCTET-STREAM format is used for file attachments on the Web with an unknown file type. These .octet-stream files are arbitrary binary data files that may be in any multimedia format. The OCTET-STREAM format was developed for Web browsers to understand that the file attachment is in an unknown file type, which also allows the user to choose to download and save the attached file in any file format that the user wants.

In other instances, the OCTET-STREAM file format is used to inform the user that the attached file may be saved in a recommended file format. This also allows the Web browser to enable the user to know the recommended file format for the attached .octet-stream file.

These OCTET-STREAM files may be opened by renaming the extension of the attached file to a specific file extension, and then by using an application with support for opening such files. For example, an .octet-stream file may be renamed to a .txt file (if it is indeed a .txt file), and Notepad may then be used to open the file. This means the user needs to know the file type of the attached .octet-stream file before renaming the file in the correct file extension.

Software that will open, convert or fix OCTET-STREAM files

Unfortunately we have not received enough suggestions for software that can open OCTET-STREAM files yet.

Try a universal file viewer

List of jay z albums in order. I would suggest that you try a universal file viewer like Free File Viewer. It can open over 200 different types of files - and very likely yours too! Download Free File Viewer.

By Prof. Jones (The File Expert)

Chief Content Editor and File Expert

Suggestions for this page? Mail me.

I'm working on a PHP application that must import an excel file into MySQL. So I need to convert the excel file to .csv format. But when I want to get its type using $_FILE['something']['type'] , I get application/octet-stream as its mime-type;
I think there is something wrong here. Because I gathered the list below as a .csv file mime-type:

What's the matter ?

Mohammad SaberiMohammad Saberi

4 Answers

In times like these, the official HTTP specification is always helpful. From RFC 2616 7.2.1 (my emphasis added):

Any HTTP/1.1 message containing an entity-body SHOULD include a Content-Type header field defining the media type of that body. If and only if the media type is not given by a Content-Type field, the recipient MAY attempt to guess the media type via inspection of its content and/or the name extension(s) of the URI used to identify the resource. If the media type remains unknown, the recipient SHOULD treat it as type 'application/octet-stream'.

The cause of your issue is that the server accepting the file upload does not itself know what type of file has been uploaded. Why? Because it relies on the the HTTP message which sent the file to specify a Content-Type header to determine the exact mime-type. The browser has likely not sent a Content-Type header and the server has assumed application/octet-stream as per the official HTTP specification excerpt above. It's also possible that the client uploading the file opted not to determine the mime type of the file it was uploading and sent the Content-Type: application/octet-stream header itself.

Now, when we consider this in conjunction with the PHP manual entry regarding POST file uploadsdocs, we see the following:

$_FILES['userfile']['type']

The mime type of the file, if the browser provided this information. An example would be 'image/gif'. This mime type is however not checked on the PHP side and therefore don't take its value for granted.

So as you can see, even if $_FILES['userfile']['type'] is specified, it only corresponds to the Content-Type header sent by the client. This information can easily be faked and should not be relied upon. If you need to be sure that the uploaded file is of a specific type, you'll have to verify that yourself.

rdlowreyrdlowrey

application/octet-stream is always used if the mime type is not known.

StrubTStrubT

All of the mime-types you listed show up as common mime-types for csv files on http://filext.com/file-extension/CSV

So basically I'd say it comes down to which program generated the .csv file and which mime-type they decided to use.

chucksmashchucksmash

$_FILE['something']['type'] is populated by the browser / user OS, so it is not reliable. You should make your own check at server side to determine if uploaded file was in desired format.

dev-null-dwellerdev-null-dweller

Not the answer you're looking for? Browse other questions tagged phpcsvhttp-headersmime-typesfile-format or ask your own question.