Foros de discusión

Inconsistent Mime Type assigned for documents uploaded via API

Ragunath A, modificado hace 7 años.

Inconsistent Mime Type assigned for documents uploaded via API

New Member Mensajes: 5 Fecha de incorporación: 22/09/16 Mensajes recientes
Hi,

In our application, we have provided pages for the user to upload the document directly into documents & media using Liferay DLFileEntry APIs. We allow users to upload macro enabled xls files. In one environment the uploaded file is stored with mimetype "application/vnd.ms-excel.sheet.macroenabled.12" whereas in the other environment where the same code is deployed, the mime type is saved as "application/vnd.ms-excel.sheet.macroEnabled.12". I can see the differences in Lifeary DLFILEENTRY_ table mimetype column.

I'm using MimeTypesUtil.getContentType(sourceFileName) to find out the mime type of the document by passing the file name with extension xlsm.

The tika-core.jar which holds the mime mappings xml is same on both of these environments that has entry "application/vnd.ms-excel.sheet.macroenabled.12" for xlsm extension. Not sure is there any other jar which has overrides that is causing this incosistency. Any help with figuring out the root cause is appreciated.
thumbnail
David H Nebinger, modificado hace 7 años.

RE: Inconsistent Mime Type assigned for documents uploaded via API

Liferay Legend Mensajes: 14915 Fecha de incorporación: 2/09/06 Mensajes recientes
Hmm, IIRC isn't mime type provided by the browser during upload? Could you be looking at perhaps a difference between browsers?





Come meet me at the LSNA!
Ragunath A, modificado hace 7 años.

RE: Inconsistent Mime Type assigned for documents uploaded via API

New Member Mensajes: 5 Fecha de incorporación: 22/09/16 Mensajes recientes
Thanks for your reply.

When I debug the post request in firebug, the mime-type is sent as "application/vnd.ms-excel.sheet.macroEnabled.12" for both of the environment urls. In our code we are using the MimeTypesUtil to find out the mime type instead of trusting browser sent value, as there are chances that different browsers will provide different values.

Need to figure out why the MimeTypesUtil is returning different values.