Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

cffile MIME types

Explorer ,
Sep 21, 2012 Sep 21, 2012

One of my users was trying to upload a Microsoft Word document using CFFILE.  The document was created in  Office 2007, but was saved in Office 2003 format (.doc).  The upload is done  with this code, which has worked in the past with PDF's:

<cftry>

    <cffile action="UPLOAD"

        filefield="file_upload"

        destination="files\temp"

        nameconflict="OVERWRITE"

        accept="application/unknown,application/pdf,application/msword,text/html,text/plain,application/rtf,text/richtext,text/xml">

        <cfset accepted="true">

<cfcatch type="any">

    <cfset accepted="false">

</cfcatch>   

</cftry>

When I cfdump the cfcatch structure after this fails, it shows the MIME type of the file that I was attempting to upload as "application/x-tika-msoffice"

When I add this MIME type to the accept parameter of cffile and try the upload again, it gives this error:

The MIME type or the Extension of the uploaded file application/x-tika-msoffice was not accepted by the server.

What can I do to allow this file to be uploaded?

I am using CF10 Standard on IIS 7.5 on Windows Server 2008R2.

Thanks.


TOPICS
Security
11.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 21, 2012 Sep 21, 2012

I wanted to mention that when I remove the accept parameter, it allows the file no problem.  Would still be nice to know why it wasn't working though, or why the Word file was sending the wrong MIME type.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 24, 2012 Sep 24, 2012

Is the error coming from CF or IIS?  It's IIS that needs to "accept" the upload.  You might have to do some jiggery-pokery (can you tell I am no IIS expert? 😉 on it to allow that MIME type to be accepted.  It might not be a CF problem.

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 24, 2012 Sep 24, 2012

Sorry, was responding to your first post, having not seen the follow-up one.

Hmmm.  Seems unlikely it's IIS that's blocking it if changes to the <cffile> call changes the behaviour.

Sorry for the bum steer on my previous post.  So I'm back to being "void of ideas" now.

I'll have a look @ it though to see if I can replicate.

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 24, 2012 Sep 24, 2012

IIS has a list of a bazillion MIME types, but "application/x-tika-msoffice" is not included in the list.  I tried to add it for the ".doc" extension, but it said that there was already a MIME type for that extension, the one that "should" be used: "application/msword".

Since I got it to work, I have moved on to bigger and better things.

Thanks.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 24, 2012 Sep 24, 2012

Since I got it to work, I have moved on to bigger and better things.

Fair enough.  I wasn't too sure if your solution of removing the MIME type was something to considered a solution, or just an observation.  Wanna mark that comment of yours as the answer?

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 24, 2012 Sep 24, 2012

I don't really consider it an answer, since the original problem wasn't solved, but worked around.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 26, 2012 Sep 26, 2012

It's the wrong mime type. For .docx it's:

   application/vnd.openxmlfor

mats-officedocument.wordprocessingml.document

http://blogs.msdn.com/b/vsofficedeveloper/archive/2008/05/08/office-2007-open-xml-mime-types.aspx

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 26, 2012 Sep 26, 2012

I was uploading a .doc, not a .docx, and my .doc file was giving the MIME type of application/x-tika-msoffice.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 18, 2012 Dec 18, 2012

Just saw this and experienced the same problem.  This has nothing to do with IIS.  I found out if you have OpenOffice installed you can only use the OO acceptable MIME types application/x-tika-msoffice or application/x-tika-ooxml .

Not sure if this is intended to be a feature or a bug, but I had to uninstall OO for my purposes, so I consider it a bug.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 18, 2012 Dec 18, 2012

I'd say definitely a bug. Even if it's "by design", it's just daft. Have you filed a bug for it?

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 18, 2012 Dec 18, 2012

Actually, doing it now.

Update: Bug 3431165

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 06, 2013 Jun 06, 2013

Stephen, just to clarify, you're saying that Open Office was installed on the ColdFusion server (not the client system)?

I was seeing the same issue, and allowing application/x-tika-msoffice and application/x-tika-ooxml appears to have addressed the issue, although Open Office wasn't installed on either the client or server.

CF10 includes Tika 0.6 (cfusion\lib\tika-core-0.6.jar and cfusion\lib\tika-parsers-0.6.jar), which presumably have something to do with the issue. I'm just not sure how uninstalling Open Office would have fixed it in your scenario.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 06, 2013 Jun 06, 2013

Correct, when OO was installed, I could not define the correct MIME type for new and legacy office formats (e.g. doc or docx) and they would not upload using cffile.   Once it was uninstalled I could define the correct type and the behavior was as expected.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 12, 2013 Jun 12, 2013

I actually reported an issue very similiar to this a few months back, my bug report went as far as being 'verified' by Adobe Developers then magically 'disappeared' without any notice.  I had several people from these forums including some of the well known CF Devs put in a vote for it.  Here is the original thread - http://forums.adobe.com/thread/1088884 and the bug report link that is currently in nowhere land - https://bugbase.adobe.com/index.cfm?event=bug&id=3343364.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 13, 2013 Jun 13, 2013

try by giving the new attribute (strict = "false") for cffile. This is the new attribute introduced in CF 10.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 13, 2013 Jun 13, 2013
LATEST

Thanks Adbul, that will be useful for CF10 users!

I noticed that the strict attribute is not listed in the ColdFusion documentation, but that a good description of its use is provided on CFFILE Restricting file types to upload.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources