使用Cordova获取文件名

时间:2018-06-18 18:49:12

标签: javascript android cordova cordova-plugins

使用Cordova,如何根据文件的URI获取带扩展名的文件名?

例如,在我的应用程序中,使用了这两个URI:

file:///storage/emulated/0/Android/data/com.myapp.mobile.subdomain/cache/IMG_20180503_125311.jpg?1529347191687

content://com.android.providers.media.documents/document/image%3A690

第一个很容易得到名字,但第二个是不可能的。

1 个答案:

答案 0 :(得分:0)

已解决的问题:

window.resolveLocalFileSystemURI('file://example.jpg', function (fileEntry) {
    fileEntry.file(function (myFile) {

        return myFile.name;

    }, function () {
        console.log('error');
    });

}, function (e) { });