• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1363
  • Last Modified:

Browser passes content-type as application/octet-stream

I have a JSP page with a file selector. User selects a document on this page and submits it to the server which then does some processing with the document.

Below is a code snippet -

<form name="import_form" id="import_form" action='<%= request.getParameter("bpurl") %>/http/upload_doc' method="post" enctype="multipart/form-data">
....
<input type="file" class="file" name="doc_import" id="doc_import" onchange="displayDocLabel(this);"/>
....
</form>

Open in new window


when the form is submitted, I have traced this request through Fiddler and noticed that for doc, docx, xls etc the content-type is getting set as application/octet-stream
Content-Disposition: form-data; name="doc_import"; filename="Troubleshooting.doc"
Content-Type: application/octet-stream

Open in new window


However for other types, like pdf, txt, png etc it is being set to the correct content-type. Example,

Content-Disposition: form-data; name="doc_import"; filename="Dok_5.pdf"
Content-Type: application/pdf

Open in new window



For .doc files, I would have expected it to be set as application/msword but that is not the case. Can someone please help me understand why this is happening and what do I need to do to correct this.

Thanks in anticipation.
0
ank5
Asked:
ank5
  • 2
  • 2
2 Solutions
 
mrcoffee365Commented:
In our system it has to do with the mime type of the file as understood by the server.  So it sounds as if your server doesn't have a mime type definitions for .docx, or if it has one, the definition is application/octet-stream.

Check the web server configuration.
0
 
COBOLdinosaurCommented:
I don't believe that there is an IANA registration that a server could use so it defaults to the general application MIME type.  I expect that like a lot of ther things MS is out of the mainstream and application/msword is probably only used internally by Office and Windows.  

However even if they exist it is not likely that a web server would be configured to something that specific and proprietary when they have very little use in a web-centric environment.

Cd&
0
 
ank5Author Commented:
the app server does have application/wsword and other mime types defined.

Upon further research I have noticed that if the end user machine (where user is using a browser to upload the file), has MS Office installed then correct mime type gets passed for all MS office formats. If there is no MS Office installed, it always passes application/octet-stream.

Is that a known limitation?
0
 
mrcoffee365Commented:
COBOLdinosaur: have to agree with some and disagree with others.  Yes, MS is proprietary.  However, all business web sites, if they do any volume and allow any upload or download of MS files, have those mime types defined in their servers.

ank5: I'm not sure what you're trying to say.  Having MS products installed is not a limitation, and not having them installed is not a limitation.  Having web servers which do not have the proprietary MS mime types is not so much a limitation (well, it can have an effect) as a business choice on the part of the web server business owners.

Is there something that you want to have happen which is not?
0
 
COBOLdinosaurCommented:
If the server s configured to recognize the Office MIME types and not using those MIME types, the the clients sending the file do not have the correct header to indicate what they are.  It is likely that a client without office does not send the correct header which I suspect would be dependent on a registry setting.

The whole issue is really irrelevant unless there is some function that requires the Office MIME type on the server.  As long as the file stores correctly; what is the issue.

Cd&
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now