Closed
Bug 1324421
Opened 8 years ago
Closed 8 years ago
function uploadFile.getContentType() return unexpected value
Categories
(Firefox :: File Handling, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 306471
People
(Reporter: dpesin, Unassigned)
Details
User Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.2)
Steps to reproduce:
Our web-application let it`s users to make some file-attachments. We use function IUploadFile.getContentType() to determine file`s mimetype, but function return unexpected value. So, we have to use temporary fix as shown in example.
This error reproduced only on Firefox of latest versions. Chrome, InternetExplorer and Firefox v30 works well.
-----
Наше веб-приложение использует вложенные файлы, для определения типа которых мы вызываем функцию IUploadFile.getContentType()
однако на самом деле возвращаются неопознанные значения, что заставляет нас использовать "костыли", как в примере ниже.
Ошибка воспроизводится только в браузере Firefox последних версий (по крайней мере, в 30х версиях такой ошибки еще не было). Под хромом и IE нормально добавляется, а Firefox 42.0 устанавливает content type "application/excel", что неверно (см. https://en.wikipedia.org/wiki/Microsoft_Excel#File_formats).
-----
Example:
import org.alfresco.repo.content.MimetypeMap; //http://docs.huihoo.com/javadoc/alfresco/4.2/repository/org/alfresco/repo/content/metadata/AbstractMetadataExtracterTest.html#mimetypeMap
import org.apache.tapestry.request.IUploadFile; //http://tapestry.apache.org/tapestry3/doc/api/org/apache/tapestry/request/IUploadFile.html#getContentType()
public static String getContentType(IUploadFile uploadFile) {
String contentType = uploadFile.getContentType();
if (RepoMimeTypeUtils.MIMETYPE_APP_OCTET.equals(contentType))
return new MimetypesFileTypeMap(RepoNodeUtils.class.getResourceAsStream("/bpms/mimetypes.txt")).getContentType(uploadFile.getFileName());
if (RepoMimeTypeUtils.MIMETYPE_TEXT_RICHTEXT.equals(contentType) || RepoMimeTypeUtils.MIMETYPE_RTF.equals(contentType))
return RepoMimeTypeUtils.MIMETYPE_APP_RTF;
// воспроизводится в firefox: выставляется не тот contentType
if ("application/excel".equals(contentType) || "xls/".equals(contentType))
return MimetypeMap.MIMETYPE_EXCEL; // "application/vnd.ms-excel"
return contentType;
}
Actual results:
uploadFile.getContentType() return "application/excel" || "xls/" || "application/save"
Expected results:
uploadFile.getContentType() return "application/vnd.ms-excel"
Updated•8 years ago
|
Keywords: regressionwindow-wanted
Comment 1•8 years ago
|
||
It's likely that the incorrect information is emanating from entries in mimeTypes.rdf, which Firefox updates when users download .xls files from websites. Some sites use made up content types due to laziness or to prevent viewing in the browser. Firefox 51 should work around that problem by no longer checking mimeTypes.rdf before checking the OS:
Bug 306471 - Upload setting wrong Content-Type for files if you downloaded files with such an extension from a server that provided the wrong Content-Type for them.
Can you test your application with the current Firefox Beta?
Unfortunately, even if that works, the change is not likely to be made in Firefox 45 ESR, so would remain a problem for a subset of your users until they switch to Firefox 52 ESR in/around mid-2017.
Updated•8 years ago
|
Keywords: regressionwindow-wanted
Updated•8 years ago
|
Component: HTML: Form Submission → File Handling
Product: Core → Firefox
Comment 4•8 years ago
|
||
Thanks!
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago
Resolution: --- → DUPLICATE
Updated•7 years ago
|
Flags: needinfo?(dpesin)
You need to log in
before you can comment on or make changes to this bug.
Description
•