Hi odd,

Thanks for the helpful report and digging through the code.

The problem occurs only if trying to detect just by extension. This
might be (indirectly) caused by:

(a) no path to a physical existent file has been provided
(b) the magic detection non being available
(c) magic detection still not yields a single result

As a solution to that problem I've implemented support for "preferred
types" similar to "preferred extensions" in guessExtension(). The fix
has been commited[1] to the mm library. The copy of the library used
by the media plugin has been updated with the latest version.

Please update to the latest version of the plugin 1.3 branch[2] that
should fix it.

- David

[1] 
http://github.com/davidpersson/mm/commit/dd82d6f8deed78e1d9fd4ed8d5eec1b98e70dbd2
[2] http://github.com/davidpersson/media

On 23 Okt., 18:20, odd <fihr87364hjkfhdjf6374hfz7z3h7...@trash-
mail.com> wrote:
> Ok, my problem is that OGG files are put in the generic category,
> instead of audio. I think i've more or less isolated the problem, in
> the transfer behavior, the "transferTo" method invokes
> "Mime_Type::guessName"
>
> transfer.php, line 345: $name = Mime_Type::guessName($mimeType ?
> $mimeType : $file);
>
> and passes the name of the file. "Mime_Type::guessName" will then
> invoke "self::guessType" in order to find out the mime type.
>
> Type.php, line 235: $mimeType = self::guessType($file,
> array('experimental' => false));
>
> Then the "guessType" method invokes "self::$glob->analyze",
>
> Type.php, line 175: $globMatch = (array) self::$glob->analyze($name);
>
> and now comes the problem, it doesn't return a single match, instead
> it returns multiple types (application/ogg, audio/x-vorbis+ogg, audio/
> x-flac+ogg, etc), and so the following check:
>
> Type.php, line 177: if (count($globMatch) === 1) {
>
> results in false, the script continues, and reaches the check whether
> the "$file" parameter is a file or a resource,
>
> Type.php, line 182: if (is_resource($file)) {
> Type.php, line 184: } elseif (is_file($file)) {
>
> since it's neither of those it ends up at
>
> Type.php, line 187: } else {
>                                                 return;
>                                         }
>
> and so it doesn't return the correct mime type, and
> "Mime_Type::guessName" returns "generic":
>
> Type.php, line 242: return 'generic';
>
> So, now i'm wondering what i could do to make it work. Should i remove
> the duplicate mime types in the glob.db file? Or is this behaviour
> maybe a bug?
>
> Regards

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to