[
https://issues.apache.org/jira/browse/CB-6094?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13911640#comment-13911640
]
Ian Clelland commented on CB-6094:
----------------------------------
I haven't been able to reproduce this yet. From your error log, it would appear
that CordovaResourceApi.remapUri is not translating the {{cdvfile://}} URL into
a {{file:///}} URL properly, but the only case where that would happen is if
the File plugin hadn't been loaded yet. If you are creating the directories
before you try to download the file, then the File plugin, I believe, *has* to
be loaded.
Because of the potential for this issue, I recently changed File to load on
startup (CB-6087). That change is just on dev now, but should be released very
soon as File v1.0.1. If you want to try using that, you can check out the dev
branch of https://github.com/apache/cordova-plugin-file, and see if that fixes
things for you.
Here is the test code that I've been running (I've tried this with both
released and dev versions of file and file-transfer, and it hasn't failed yet):
{code}
window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(fileSystem) {
var omadir = 'user1';
fileSystem.root.getDirectory('1oma/', {create: true}, function (dirEntry) {
fileSystem.root.getDirectory('1oma/' + omadir, {create: true}, function
(dirUser) {
alert("Created both directories");
var movieURL =
"http://techslides.com/demos/sample-videos/small.mp4";
var ft = new FileTransfer();
ft.download(movieURL, dirUser.toURL() + "/movie.mp4",
function(entry) {
alert("Download successful");
console.log(entry);
}, function(err) { alert("Download failure: " +
JSON.stringify(err)); });
}, function(err) { alert("2nd getDirectory failure: " +
JSON.stringify(err)); });
}, function(err) { alert("1st getDirectory failure: " +
JSON.stringify(err)); });
}, function(err) { alert("requestFileSystem failure: " + JSON.stringify(err));
});
{code}
After running it, I'm checking the file system on the device:
{code}
macbookpro:~/dltest$ adb shell
shell@flo:/ $ cd /sdcard/1oma/
shell@flo:/sdcard/1oma $ ls
user1
shell@flo:/sdcard/1oma $ cd user1/
shell@flo:/sdcard/1oma/user1 $ ls -l
-rw-rw---- root sdcard_r 383631 2014-02-25 09:41 movie.mp4
shell@flo:/sdcard/1oma/user1 $
{code}
> Cordova 3.4.0 Filetransfer download Error Code 1
> ------------------------------------------------
>
> Key: CB-6094
> URL: https://issues.apache.org/jira/browse/CB-6094
> Project: Apache Cordova
> Issue Type: Bug
> Components: Android, Plugin File Transfer
> Affects Versions: 3.4.0
> Reporter: Torsten Rosenberger
> Assignee: Ian Clelland
> Labels: javascript
>
> Hello
> I update my phonegap 3.0.1 to cordova 3.4.0.
> But the same code which worked on 3.0.1 throw now a error
> during downloading a file.
> First i request a filesystem
> window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(fileSystem)
> all ok, then create a directory also ok.
> remoteFile = 'http://www.example.com/myfile.png'
> localPath = '/mydir/myfile.png'
> var ft = new FileTransfer();
> ft.download(remoteFile,localPath, function(entry) {
> },
> function(error) {
> console.log(error);
> console.log("download error source " + error.source);
> console.log("download error target " + error.target);
> console.log("download error code" + error.code);
> }
> );
> in mydir Directory the File myfile.png ist created with a size of 0
> Bytes.
> and i got the error Code 1 (FILE_NOT_FOUND_ERR)
> if i add file://mnt/sdcard/ to the localPath Variable the download is
> sucessfull. But with the new Version i get
> / for the fileSystem.root.fullPath as descriped in the changlog of 3.4.0
> maybe i doing something wrong with the new filesystem path to the root
> directory ?
> BR/Torsten
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)