Solved

Browser passes content-type as application/octet-stream

Posted on 2014-02-24
5
1,078 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 27

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 27

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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 to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

911 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

16 Experts available now in Live!

Get 1:1 Help Now