Solved

Browser passes content-type as application/octet-stream

Posted on 2014-02-24
5
1,060 Views
Last Modified: 2014-03-08
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
Comment
Question by:ank5
  • 2
  • 2
5 Comments
 
LVL 26

Expert Comment

by:mrcoffee365
ID: 39886875
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
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 250 total points
ID: 39887373
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
 
LVL 1

Author Comment

by:ank5
ID: 39887629
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
 
LVL 26

Assisted Solution

by:mrcoffee365
mrcoffee365 earned 250 total points
ID: 39887964
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
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 39888802
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Introduction The Google Maps API offers various ways to draw dynamic and static maps.  Using a combination of PHP and JavaScript, you can draw active JavaScript maps that allow pan-and-zoom in the client browser window.  You can also draw "static" …
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now