I'm trying to upload a file from Android filesystem via resumable.js. I set up my Resumable-Object and use .fileAdd to add the file I requested from the local filesystem. According to the Documentation the event 'fileAdded' should be fired if a file was added. But it isn't. So, is it possible at all to add a file from file system or do I have to use the '.assignBrowse'-Method to add a file from UI ?
Here's what I did:
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem){
var resumable = new Resumable({
target: 'v16/chunk',
chunkSize: 1024 * 128
});
fileSystem.root.getFile(theFileName, {create: false}, function(fileEntry){
resumable.addFile(fileEntry); // File from file system
console.log("manual add");
resumable.files.forEach(function(item){
// log the added files
console.log(item.fileName);
console.log(item.relativePath); // undefined
console.log(item.size); // NaN
});
console.log("Size " + resumable.getSize()); // NaN
resumable.on('fileAdded', function(file){
console.log("File Added"); // Shouldn't this be called?
resumable.upload();
});
}, that.get('fail'));
}, that.get('fail'));
Boah simple as it is, i just have to switch the order of
resumable.on(...)
andresumable.addFile(...)
. Now it looks like this: