[xwiki-users] How to specify mime-type for MSOffice-2007 document attachments
Hi. I am test driving XWiki Enterprise for my group at work. Kudos and thanks to the developers for putting together this fabulous app. I am having trouble with MSOffice-2007 documents attached to pages in the wiki. The content-type header delivered by the server when accessing such documents (with extensions .pptx, .docx or .xlsx for example) is "application/octet-stream". While modern browsers such as Firefox offer to open the document in the appropriate app (looking at the filename in the content-disposition header I guess), IE6 unfortunately treats it as binary data and offers to open it with WinZip. I have read through a couple of threads in the xwiki-dev and xwiki-users mailing list archive, but following those directions did not resolve my issue. So how can I fix this issue? I have tried adding mime-mapping in <install-root>/domain/domain1/config/default-web.xml as well as in <install-root>/domain/domain1/applications/j2ee-modules/xwiki-enterprise-web-2.1-milestone-1/WEB-INF/web.xml like following -- but that has had no effect. <mime-mapping> <extension>docx</extension> <mime-type>application/vnd.openxmlformats</mime-type> </mime-mapping> <mime-mapping> <extension>pptx</extension> <mime-type>application/vnd.openxmlformats</mime-type> </mime-mapping> <mime-mapping> <extension>xlsx</extension> <mime-type>application/vnd.openxmlformats</mime-type> </mime-mapping> The content-type header still comes as application/octet-stream as shown below: bash> lynx http://<myhost>/xwiki/bin/download/Sandbox/TestPage2/simple.xlsx -head -dump HTTP/1.1 200 OK Server: Sun Java System Application Server 9.1_01 Set-Cookie: JSESSIONID=1556df25ad03500b4592d778a5e1; Path=/xwiki Content-disposition: inline; filename="simple.xlsx" Last-Modified: Wed, 02 Dec 2009 17:37:17 GMT Set-Cookie: visitid=NMUOTURHA9P7GS5BM35MKJLN5WQSPYDL; Path=/ Content-Type: application/octet-stream;charset=ISO-8859-1 Content-Language: en I have verified by introducing syntax errors and by other techniques that the web.xml file is being read by the server when I perform a restart, but the mime-mapping additions seem to have no effect. Any help will be deeply appreciated. Thanks, Milind
On 12/03/2009 12:09 AM, Milind Kamble wrote:
Hi. I am test driving XWiki Enterprise for my group at work. Kudos and thanks to the developers for putting together this fabulous app.
I am having trouble with MSOffice-2007 documents attached to pages in the wiki. The content-type header delivered by the server when accessing such documents (with extensions .pptx, .docx or .xlsx for example) is "application/octet-stream". While modern browsers such as Firefox offer to open the document in the appropriate app (looking at the filename in the content-disposition header I guess), IE6 unfortunately treats it as binary data and offers to open it with WinZip.
I have read through a couple of threads in the xwiki-dev and xwiki-users mailing list archive, but following those directions did not resolve my issue.
So how can I fix this issue? I have tried adding mime-mapping in <install-root>/domain/domain1/config/default-web.xml as well as in <install-root>/domain/domain1/applications/j2ee-modules/xwiki-enterprise-web-2.1-milestone-1/WEB-INF/web.xml like following -- but that has had no effect.
<mime-mapping> <extension>docx</extension> <mime-type>application/vnd.openxmlformats</mime-type> </mime-mapping> <mime-mapping> <extension>pptx</extension> <mime-type>application/vnd.openxmlformats</mime-type> </mime-mapping> <mime-mapping> <extension>xlsx</extension> <mime-type>application/vnd.openxmlformats</mime-type> </mime-mapping>
Yes, this looks correct. In theory it should work. Make sure that you put this in the right place in the web.xml file, since the order of the elements matters. Search for the other mime-mapping elements already present in the file, and add your mappings next to those. If it still doesn't work, then it could be the app container. Which server are you using?
The content-type header still comes as application/octet-stream as shown below:
bash> lynx http://<myhost>/xwiki/bin/download/Sandbox/TestPage2/simple.xlsx -head -dump HTTP/1.1 200 OK Server: Sun Java System Application Server 9.1_01 Set-Cookie: JSESSIONID=1556df25ad03500b4592d778a5e1; Path=/xwiki Content-disposition: inline; filename="simple.xlsx" Last-Modified: Wed, 02 Dec 2009 17:37:17 GMT Set-Cookie: visitid=NMUOTURHA9P7GS5BM35MKJLN5WQSPYDL; Path=/ Content-Type: application/octet-stream;charset=ISO-8859-1 Content-Language: en
I have verified by introducing syntax errors and by other techniques that the web.xml file is being read by the server when I perform a restart, but the mime-mapping additions seem to have no effect.
Any help will be deeply appreciated.
-- Sergiu Dumitriu http://purl.org/net/sergiu/
Thanks for your prompt reply Sergiu. My response is inlined below. ----- Original Message ----
From: Sergiu Dumitriu <[email protected]> To: XWiki Users <[email protected]> Sent: Thu, December 3, 2009 12:31:16 AM Subject: Re: [xwiki-users] How to specify mime-type for MSOffice-2007 document attachments
On 12/03/2009 12:09 AM, Milind Kamble wrote:
Hi. I am test driving XWiki Enterprise for my group at work. Kudos and thanks to the developers for putting together this fabulous app.
I am having trouble with MSOffice-2007 documents attached to pages in the wiki. The content-type header delivered by the server when accessing such documents (with extensions .pptx, .docx or .xlsx for example) is "application/octet-stream". While modern browsers such as Firefox offer to open the document in the appropriate app (looking at the filename in the content-disposition header I guess), IE6 unfortunately treats it as binary data and offers to open it with WinZip.
I have read through a couple of threads in the xwiki-dev and xwiki-users mailing list archive, but following those directions did not resolve my issue.
So how can I fix this issue? I have tried adding mime-mapping in /domain/domain1/config/default-web.xml as well as in
/domain/domain1/applications/j2ee-modules/xwiki-enterprise-web-2.1-milestone-1/WEB-INF/web.xml
like following -- but that has had no effect.
docx application/vnd.openxmlformats
pptx application/vnd.openxmlformats
xlsx application/vnd.openxmlformats
Yes, this looks correct. In theory it should work. Make sure that you put this in the right place in the web.xml file, since the order of the elements matters. Search for the other mime-mapping elements already present in the file, and add your mappings next to those.
If it still doesn't work, then it could be the app container. Which server are you using?
I had placed the edits in the correct place as you have suggested. I was using Sun Java System Application Server 9.1_01. Our system admin then reinstalled Glassfish 2.2.1 and I saw the same behavior. Finally, when I deleted the domains/domain1/generated directory (after stopping the server) and restarted the server, we saw that the new mime types added to web.xml were being correctly used and delivered for the content-type header based on the file extension. Can anyone shed light on what the "generated" directory is meant for (atleast for Sun Java servers) ? And why do edits made in xwiki's WEB-INF/web.xml file not get "regenerated" into the generated directory? My workaround therefore is to delete the generated directory before restarting the server.
The content-type header still comes as application/octet-stream as shown below:
bash> lynx http:///xwiki/bin/download/Sandbox/TestPage2/simple.xlsx -head -dump HTTP/1.1 200 OK Server: Sun Java System Application Server 9.1_01 Set-Cookie: JSESSIONID=1556df25ad03500b4592d778a5e1; Path=/xwiki Content-disposition: inline; filename="simple.xlsx" Last-Modified: Wed, 02 Dec 2009 17:37:17 GMT Set-Cookie: visitid=NMUOTURHA9P7GS5BM35MKJLN5WQSPYDL; Path=/ Content-Type: application/octet-stream;charset=ISO-8859-1 Content-Language: en
I have verified by introducing syntax errors and by other techniques that the web.xml file is being read by the server when I perform a restart, but the mime-mapping additions seem to have no effect.
Any help will be deeply appreciated.
-- Sergiu Dumitriu http://purl.org/net/sergiu/ _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
participants (2)
-
Milind Kamble -
Sergiu Dumitriu