Issues

ZF-5709: File extension to MIME type database

Issue Type: New Feature Created: 2009-02-06T10:35:09.000+0000 Last Updated: 2011-01-13T19:02:47.000+0000 Status: Resolved Fix version(s): Reporter: Stanislav Malyshev (stas) Assignee: None Tags: - Zend_Mime

Related issues: Attachments:

Description

We should have the database of MIME types with relation to file extensions in Zend_MIME for use of various modules such as file transfer services, etc. It seems to be the most logical place to put such thing to.

This can be further extended by having finfo (file magic) interface which will guess file MIME not only but extension but also content. finfo is in standard PHP starting 5.3 but in PECL before that.

Comments

Posted by thing2b (thing2b) on 2009-06-30T19:15:26.000+0000

This could also help replace the getMimeType() method on Zend_Service_Amazon_S3, which converts file extensions to mime types.

Posted by Nico Edtinger (nico) on 2009-07-01T04:11:27.000+0000

There's a great list of file extensions and mime types in one of the apache config files: http://svn.apache.org/viewvc/httpd/… Maybe we could use that one.The last comment says it's in the public domain.

Beside finfo (which is part of PHP 5.3 IIRC) we can also use getimagesize().

I see how I get time to write a little guesser class. But I don't have a problem if anyone else is quicker ;)

Posted by Satoru Yoshida (satoruyoshida) on 2009-11-11T21:48:19.000+0000

It seems to be also one of issues for next major release like as ZF-1490 . Do you have any idea ?

Posted by Satoru Yoshida (satoruyoshida) on 2009-11-28T06:27:05.000+0000

I will note on here http://framework.zend.com/wiki/display/…

Posted by Satoru Yoshida (satoruyoshida) on 2009-12-04T21:45:14.000+0000

IMO, it seems to be better that we would submit a new proposal. Because I think this issue might be new feature rather than expansion of existing Zend_Mime.

I expect the class name with Zend_Filter_File_MimeType as one of converters about file's infomation, or Zend_Mime_Type as specialty handler of Mime types.

The class might have 2 kinds method.

  1. Simple converter from file's extension to MIME type. for example, getTypeByExtension(). it may be required for getMimeType() of Zend_Service_Amazon_S3 (mentioned by thing2b).

  2. Information extracter from file with finfo() or getimagesize(). For example, getTypeByFinfo(). Or we might substitute it by getMimeType() of Zend_File_Transfer_Adapter

I hope it could help you ;)

Posted by Thomas Weidner (thomas) on 2009-12-05T01:50:32.000+0000

Note that Zend_Filter is not the correct component for getting the mimetype of an file.

Posted by Thomas Weidner (thomas) on 2009-12-05T01:50:53.000+0000

Detaching Zend_Filter

Posted by Thomas Weidner (thomas) on 2009-12-05T01:57:44.000+0000

Note that finfo is availalble also to 5.2.4 installations.

Zend_Mime was designed ONLY for usage with Zend_Mail. Therefor it is not used in other places of the framework.

Note that Zend_File_Transfer is ONLY for usage while transferring a file, and not for existing files somewhere in a directory. When you let file-transfer detect the mime type based on the extension as proposed abbove it's a VERY HUGE security risk.

The base question is, if we want to couple two components more together for a functionallity which is available within vanilla PHP installations. I would say no.

Posted by thing2b (thing2b) on 2009-12-05T14:32:47.000+0000

You say that "Zend_Mime was designed ONLY for usage with Zend_Mail." If this is the case, why was Zend_Mime not called Zend_Mail_Mime?

Posted by Satoru Yoshida (satoruyoshida) on 2009-12-06T04:17:40.000+0000

Thank You opinions, Thomas and thing2b .

I will be happy if reporter or participants would submit proposal. Because the MIME type database seems to be independent with the existing Zend_Mime functions and also Zend_Mail one.

Rather, it is required with other components. It would be better to ask review for many reviewers about the database .

Posted by Stanislav Malyshev (stas) on 2009-12-07T00:16:33.000+0000

I don't see why Zend_Mime can't be used whenever we need to do something with MIME. What in Zend_Mime prevents us from using it anywhere we want to?

BTW, having good list of MIME types for files can help mailing too, if you are mailing files. But doesn't have to be for mail exclusively.

Posted by mayhem (mayhem) on 2011-01-13T12:47:57.000+0000

So what the results of this talking? I'm also interested to have tools to work with mime, and as we all can see this tools implemented in wide range of components, and all this components has its own realisation.

Posted by Satoru Yoshida (satoruyoshida) on 2011-01-13T19:02:45.000+0000

Sorry, I became inactive since last April.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts