我想了几个小时使用HTML5文件系统添加远程文件与URL(如http://example.com/doc.pdf)(我,因为我想要的过程是自动的通过将文件输入获得的文件,而不是有一个以上的文档),但我没有找到有关进程什么...HTML5文件API与远程文件
所有的例子,我发现关注本地文件(添加文件输入)...
我给你的几行我的代码:
window.requestFileSystem(TEMPORARY, 1024 * 1024 * 10, function(fs) {
FS_ = fs;
addRemoteDocuments();
}, errorCallback);
function addRemoteDocuments(){
var docList = [ "http://cpbdev/html5tests/pdf/tarifs.pdf", "http://cpbdev/html5tests/pdf/tarifs1.pdf", "http://cpbdev/html5tests/pdf/tarifs2.pdf", "http://cpbdev/html5tests/pdf/tarifs3.pdf", "http://cpbdev/html5tests/pdf/tarifs4.pdf" ];
for (var i = 0, doc; doc = this.docList[i]; ++i) {
// Capture current iteration's file in local scope for the getFile() callback.
(function(f) {
FS_.root.getFile(getName(doc), {create: true, exclusive: true}, function(fileEntry) {
fileEntry.createWriter(function(fileWriter) {
fileWriter.onwriteend = function(e) {
console.log('Write completed for doc '+i);
};
fileWriter.write(GET_REMOTE_FILE(doc));
}, errorCallback);
}, errorCallback);
})(doc);
}
readDirectories();
}
function GET_REMOTE_FILE(doc){
//Impossible to find a way to get File (with possibility to use file.name and others properties)
}
也许用模拟点击隐藏fil输入E(如果有可能增加一个远程文件...)
我希望有人能帮助我,因为有关远程文件和文件系统的文档都很难找到...
谢谢大家:)
布莱斯。
什么是你想怎么办?通过文件API下载远程文件? – mpm 2012-02-28 16:32:12
我想将远程文件添加到本地文件系统。 (离线后访问它们) – Pouki 2012-02-28 16:35:36