[ 
https://issues.apache.org/jira/browse/CB-8103?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

W. Matthew Wilson updated CB-8103:
----------------------------------
    Description: 
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}


  was:
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}



> 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}



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to