not recognizing the ZIP mime-type (application/zip)

itaine - April 25, 2009 - 12:32
Project:MimeDetect
Version:6.x-1.1
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

When I set the 'permitted upload file extensions' to: zip rar
I'm getting the following when uploading a zip file:
"The selected file template.zip could not be uploaded. The file contents (application/x-zip) do not match its extension (zip)."

#1

quicksketch - April 25, 2009 - 12:50
Project:FileField» MimeDetect
Version:6.x-3.x-dev» 6.x-1.1

Sounds like mimedetect isn't working properly to identify the file type. Have you set up the "file" command at admin/settings/mimedetect? It would probably help identify the problem if you could upload the file to drupal.org or if it's a large file, make it available for download elsewhere.

#2

itaine - April 25, 2009 - 13:46

thx for the quick response! Let me look into the mimedetect settings first and report back shortly.
Have you set up the "file" command at admin/settings/mimedetect?
when I go there I get the following
"The MimeDetect module is using PHP's fileinfo extension to detect MIME types. There are no settings for the extension. "

I unzipped the archive and rezipped it myself to make sure it actually a zip file. I will attach it though. Checked to make sure the php_fileinfo extension is active and it is. Mind you I'm of course testing on a wamp setup not sure if it requires to be on a UNIX server to work.

#3

itaine - April 25, 2009 - 13:42
AttachmentSize
template.zip 3.21 KB

#4

itaine - April 25, 2009 - 14:25

ok I've narrowed it down. Everything works as it should. It appears there is just a problem with the application/zip mime-type. I will update the title of this issue to reflect that.

#5

itaine - April 25, 2009 - 14:28
Title:Permitted upload file extensions not working» not recognizing the ZIP mime-type (application/zip)

#6

drewish - April 25, 2009 - 21:11

yeah i think the magic library we ship is kind of limited. i'm not sure how to write a signature for it for zip files. might be better to use the system's if available. there's an issue for making the mime file customizable.

#7

itaine - April 26, 2009 - 23:14

when you say the system's are you referring to the upload module?

#8

billnbell - May 8, 2009 - 09:05

It appears that fileinfo and file relies on a magic file. If this file is not current, this module will not work.

From the command line type "file filename" and it should something other than zip.

#9

quicksketch - May 8, 2009 - 21:41
Status:active» needs review

This patch does two things: 1) Updates our magic file so that it returns "application/zip" instead of "application/x-zip" so that it matches file_get_mimetype() and 2) Makes mimedetect actually use the magic file. Right now it looks like we're shipping mimedetect with a magic file, but not actually using it anywhere.

AttachmentSize
mimedetect_use_magic.patch 1.98 KB

#10

drewish - May 8, 2009 - 21:57

Right now it looks like we're shipping mimedetect with a magic file, but not actually using it anywhere.

Definitely a bug but technically we are using it with the PHP mimedetech extension, just not the file command...

#11

quicksketch - May 8, 2009 - 22:12

technically we are using it with the PHP mimedetech extension, just not the file command

Ah, right I hadn't seen that reference. It'd definitely be handy to use the same magic file in both places.

#12

drewish - May 9, 2009 - 17:42
Status:needs review» fixed

minor tweak. committed to HEAD, D6 and D5.

AttachmentSize
mimedetect_444724.patch 2.51 KB
mimedetect_444724.D7.patch 2.53 KB

#13

quicksketch - May 10, 2009 - 03:00

Works great, thanks drewish.

#14

System Message - May 24, 2009 - 03:10
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.