Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get mimeType from Cordova File Transfer Plugin?

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)

like image 909
sannith rao Avatar asked Dec 15 '15 05:12

sannith rao


People also ask

How do I find the MIME type of a file?

For detecting MIME-types, use the aptly named "mimetype" command. It has a number of options for formatting the output, it even has an option for backward compatibility to "file". But most of all, it accepts input not only as file, but also via stdin/pipe, so you can avoid temporary files when processing streams.

What is the MIME type of a file?

A media type (also known as a MIME type) is a two-part identifier for file formats and format contents transmitted on the Internet. The Internet Assigned Numbers Authority (IANA) is the official authority for the standardization and publication of these classifications.

What is Cordova plugin file transfer?

This plugin allows you to upload and download files. This plugin defines global FileTransfer , FileUploadOptions constructors. Although in the global scope, they are not available until after the deviceready event.


1 Answers

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
});
like image 121
wathmal Avatar answered Sep 30 '22 12:09

wathmal