使用org.apache.cordova.file获取所选文件大小 [英] Get selected file size using org.apache.cordova.file
本文介绍了使用org.apache.cordova.file获取所选文件大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用org.apache.cordova.file插件,我可以选择的文件,我得到的文件的本地路径。从那以后,我一定要限制用户根据有文件的大小来选择文件。但我不能得到的文件大小。我的问题是,我无法使用该插件下载文件大小。对于这个我使用本教程。一>
Using org.apache.cordova.file plugin I can selected the file and I get the native path of the file. After that I have to restrict the user to select the file according to there file size. But I can't get that file size. My problem is that I can't get the file Size using that plugin. For this I am using this tutorial.
推荐答案
要获取文件大小,则需要通过元数据访问,如下所示:
To get file size, you need to access it via metadata as follows:
window.resolveLocalFileSystemURL(filePath,
function (fileSystem) {
fileSystem.getFile(fileName, {create: false},
function (fileEntry) {
fileEntry.getMetadata(
function (metadata) {
alert(metadata.size); // get file size
},
function (error) {}
);
},
function (error) {}
);
},
function (error) {}
);
这篇关于使用org.apache.cordova.file获取所选文件大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文