cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ian Clelland (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-8103) file method on local file returns mime type "video/3gpp" for .mp4 files
Date Mon, 22 Dec 2014 15:29:13 GMT

    [ https://issues.apache.org/jira/browse/CB-8103?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14255831#comment-14255831
] 

Ian Clelland commented on CB-8103:
----------------------------------

The mime type of the file doesn't depend on the filename at all -- they should be completely
separate things.

Cordova uses [{{android.content.ContentResolver.getType}}|http://developer.android.com/reference/android/content/ContentResolver.html#getType(android.net.Uri)]
to determine the type of the file, which should be correct, according to its actual contents.

(However, 3GPP and MP4 are both extensions of the same spec (MPEG-4 part 12) and may actually
be compatible in some cases, regardless of the extension or the detected mime type.)

> file method on local file returns mime type "video/3gpp" for .mp4 files
> -----------------------------------------------------------------------
>
>                 Key: CB-8103
>                 URL: https://issues.apache.org/jira/browse/CB-8103
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, Plugin File
>    Affects Versions: 3.6.3
>            Reporter: W. Matthew Wilson
>
> I have a feature in my app where a user can pick a video from their gallery and then
upload it to a remote server.
> I need the mime type of the file because right now, I can only process .mp4 files, not
.3gp files.
> I'm using something like this code:
> {code}
> window.resolveLocalFileSystemURL(
>     local_video_path, // something like "/media/external/video/media/971"
>     function (f) {
>         console.debug("inside resolveLocalFileSystemURL callback", f);
>         f.file(function (fo) {
>             console.debug("fo", fo);
>             if (fo.size > 30 * 1000 * 1000) {
>                 navigator.notification.alert("Sorry, that file is too big!  Pick one
less than 30 mb.");
>             } else if (fo.type == "video/3gpp") {
>                 navigator.notification.alert("Sorry, that file is a .3gp file and we
can't handle those!");
>             } else {
>                 // handle file...
>             }
>         });
> {code}
> And when I pick a file that ends with .mp4, in the file(...) function callback the mime
type is set to 3gpp:
> {code}
> inside resolveLocalFileSystemURL callback 
> FileEntry {isFile: true, isDirectory: false, name: "971", fullPath: "/media/external/video/media/971",
filesystem: FileSystem…}
> filesystem: FileSystem
> fullPath: "/media/external/video/media/971"
> isDirectory: false
> isFile: true
> name: "971"
> nativeURL: "file:///storage/emulated/0/DCIM/Camera/20141117_122122.mp4"
> __proto__: utils.extend.F
>  phonegapsend.js:818
> fo 
> File {name: "content", localURL: "content://media/external/video/media/971", type: "video/3gpp",
lastModified: 1416244890, lastModifiedDate: 1416244890…}
> end: 16515092
> lastModified: 1416244890
> lastModifiedDate: 1416244890
> localURL: "content://media/external/video/media/971"
> name: "content"
> size: 16515092
> start: 0
> type: "video/3gpp"
> __proto__: Object
> {code}
> That's not a very pretty example, but I do resolveLocalFileSystem on a file "/media/external/video/media/971",
and the native URL for that file is "file:///storage/emulated/0/DCIM/Camera/20141117_122122.mp4".
> Then I use the file(...) method to look up the size and the type of that file, I get
told that the type is "video/3gpp".  That doesn't make sense to me!
> Am I doing something wrong or is this a bug?
> Let me know if there is more information I should provide.
> Go PhoneGap!



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message