How to get mimeType from Cordova File Transfer Plugin?

sannith rao picture sannith rao · Dec 15, 2015 · Viewed 7.1k times · Source

I am developing hybrid mobile application.

In one of the scenario we need to fetch mimeType from a file when we select or upload a file.

I am using apache FileTransfer.

window.resolveLocalFileSystemURL(fileURI , resolveOnSuccess, resolveOnFail)

Answer

wathmal picture wathmal · Mar 18, 2016

you can get it from cordova File plugin.

$cordovaFile.checkFile(uri, '')
.then(function(entry) {
    // success
    var name = entry.name;

    entry.file(function(data) {
        // get mime type
        var mime = data.type;
        alert(mime);
    })

}, function(error) {
    // error
    // show toast
});