Error code 3 with FileTransfer.download and 1.5

5,654 views
Skip to first unread message

Mike

unread,
Mar 28, 2012, 6:16:20 PM3/28/12
to phonegap
Hi,

I was trying to add fileTransfer.Download to my project and kept
getting error code 3, anyhow after trying many of things it was still
a no go but when I built it with pg 1.41 it worked fine.

Mike.

Simon MacDonald

unread,
Mar 29, 2012, 12:16:06 PM3/29/12
to phon...@googlegroups.com
That's a connection error. Did you white list the domain you are
downloading from?

Simon Mac Donald
http://hi.im/simonmacdonald

> --
> You received this message because you are subscribed to the Google
> Groups "phonegap" group.
> To post to this group, send email to phon...@googlegroups.com
> To unsubscribe from this group, send email to
> phonegap+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/phonegap?hl=en?hl=en
>
> For more info on PhoneGap or to download the code go to www.phonegap.com

Alex

unread,
Apr 7, 2012, 9:51:50 AM4/7/12
to phon...@googlegroups.com
Hi Mike,

I have the same problem with Samsung Galaxy S2, Android API 8 and cordova 1.5.
If I use instead PhoneGap 1.4.1 the download worked fine.

You have fixed it?

thanks,

Alex

Alex

unread,
Apr 7, 2012, 9:56:59 AM4/7/12
to phon...@googlegroups.com
Hi Simon,

phonegap is configured as follows:
<access origin=".*"/>

Do you have ideas to help us?

Thanks,
Alex

On Thursday, March 29, 2012 6:16:06 PM UTC+2, Simon wrote:
That's a connection error. Did you white list the domain you are
downloading from?

Simon Mac Donald
http://hi.im/simonmacdonald

On Wed, Mar 28, 2012 at 6:16 PM, Mike <web...@gmail.com> wrote:
> Hi,
>
> I was trying to add fileTransfer.Download to my project and kept
> getting error code 3, anyhow after trying many of things it was still
> a no go but when I built it with pg 1.41 it worked fine.
>
> Mike.
>
> --
> You received this message because you are subscribed to the Google
> Groups "phonegap" group.
> To post to this group, send email to phon...@googlegroups.com
> To unsubscribe from this group, send email to

Simon MacDonald

unread,
Apr 9, 2012, 10:42:12 AM4/9/12
to phon...@googlegroups.com
Can you guys show what is happening in "adb logcat"? Also, what is going on in your web server logs?
--
You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to

jjboucheron

unread,
Apr 10, 2012, 1:18:24 PM4/10/12
to phonegap
Hi,

It's the first time I use this kind of forum and I'm not sure you'll
get my answer... Anyway I had the same problem. My problem was that
the file wasn't created before I try to put content (image for me) in
it. I'm joining the code I used. It might help you.



<!DOCTYPE html>
<html>
<head>
<title>Contact Example</title>

<script type="text/javascript" charset="utf-8"
src="javascript/cordova-1.5.0.js"></script>
<script type="text/javascript" charset="utf-8" src="javascript/
db.js"></script>
<script type="text/javascript" charset="utf-8">

// Wait for PhoneGap to load
//
document.addEventListener("deviceready", onDeviceReady, false);


// PhoneGap is ready
//
function onDeviceReady() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotPath,
null);
}

function gotPath(fileSystem) {
console.log(fileSystem.name);
console.log(fileSystem.root.name);
// Get the data directory, creating it if it doesn't exist.

dataDir =
fileSystem.root.getDirectory("data/"+YOUR_APPLICATION_NAME, {create:
true},onSuccessTest, onFailTest);



}

// called when directory has been succesful got or created
function onSuccessTest(parent){
console.log("Parent Name: " + parent.name);
// file creation
lockFile = parent.getFile(YOUR_FILE_NAME, {create: true},
succ, failCF);

}

// called when file has been successfully created
function succ(file){
console.log("toto"+ file.fullPath);
// in order to remove the "file:/" start
filePath=file.fullPath.substr(6);
console.log(filePath);
var fileTransfer = new FileTransfer();
url = YOUR_URL;
fileTransfer.download(
url,
filePath,
function(entry) {
console.log("download complete: " + entry.fullPath);
},
function(error) {
console.log("download error source " +
error.source);
console.log("download error target " +
error.target);
console.log("upload error code" + error.code);
}
);
}

function failCF(){
console.log("File creation error");
}

function onFailTest(){
console.log("Error message");
}


</script>
</head>
<body>
<h1>Example</h1>
<p>Database</p>
</body>
</html>

Hope It'll help :)



On Apr 7, 3:51 pm, Alex <alessandro.pag...@gmail.com> wrote:
> Hi Mike,
>
> I have the same problem with Samsung Galaxy S2, Android API 8 and cordova
> 1.5.
> If I use instead PhoneGap 1.4.1 the download worked fine.
>
> You have fixed it?
>
> thanks,
>

cory03

unread,
Apr 10, 2012, 9:54:55 PM4/10/12
to phonegap
Add <feature name="http://api.phonegap.com/1.0/file"/> to the
config.xml

Robert

unread,
Apr 13, 2012, 5:20:36 PM4/13/12
to phonegap
I too get this error. Works on iOS, not on Android. Same whitelist
configuration as Alex, I think wide open. I reduced my test to simply
trying to hit a publicly available image. I can view it successfully,
but when I try to download it, here's what I get. I'm first creating
the directory and file, then using the fullPath of that fileEntry as
the target for the file transfer.

my application logging
04-13 21:02:35.743: DEBUG/CordovaLog(224): file:///android_asset/www/index.html:
Line 68 : gotFS
04-13 21:02:36.693: DEBUG/CordovaLog(224): file:///android_asset/www/index.html:
Line 78 : gotDirectoryEntry
04-13 21:02:37.174: DEBUG/CordovaLog(224): file:///android_asset/www/index.html:
Line 83 : gotFileEntry
04-13 21:02:37.255: DEBUG/CordovaLog(224): file:///android_asset/www/index.html:
Line 85 : result: file:///sdcard/mydir/test.png

cordova logging
04-13 21:02:39.863: DEBUG/FileTransfer(224): Download file:https://
www.google.com/images/nav_logo107.png
04-13 21:02:40.173: DEBUG/FileTransfer(224): /file:/sdcard/mydir/
test.png
04-13 21:02:40.173: DEBUG/FileTransfer(224):
java.io.FileNotFoundException: /file:/sdcard/mydir/test.png
04-13 21:02:40.173: DEBUG/FileTransfer(224): at
org.apache.harmony.luni.platform.OSFileSystem.open(OSFileSystem.java:
244)
04-13 21:02:40.173: DEBUG/FileTransfer(224): at
java.io.FileOutputStream.<init>(FileOutputStream.java:97)
04-13 21:02:40.173: DEBUG/FileTransfer(224): at
java.io.FileOutputStream.<init>(FileOutputStream.java:69)
04-13 21:02:40.173: DEBUG/FileTransfer(224): at
org.apache.cordova.FileTransfer.download(FileTransfer.java:412)
04-13 21:02:40.173: DEBUG/FileTransfer(224): at
org.apache.cordova.FileTransfer.execute(FileTransfer.java:102)
04-13 21:02:40.173: DEBUG/FileTransfer(224): at
org.apache.cordova.api.PluginManager$1.run(PluginManager.java:150)
04-13 21:02:40.173: DEBUG/FileTransfer(224): at
java.lang.Thread.run(Thread.java:1096)
04-13 21:02:40.204: ERROR/FileTransfer(224): Error while downloading
04-13 21:02:40.204: ERROR/FileTransfer(224): java.io.IOException:
Error while downloading
04-13 21:02:40.204: ERROR/FileTransfer(224): at
org.apache.cordova.FileTransfer.download(FileTransfer.java:429)
04-13 21:02:40.204: ERROR/FileTransfer(224): at
org.apache.cordova.FileTransfer.execute(FileTransfer.java:102)
04-13 21:02:40.204: ERROR/FileTransfer(224): at
org.apache.cordova.api.PluginManager$1.run(PluginManager.java:150)
04-13 21:02:40.204: ERROR/FileTransfer(224): at
java.lang.Thread.run(Thread.java:1096)


On Apr 9, 7:42 am, Simon MacDonald <simon.macdon...@gmail.com> wrote:
> Can you guys show what is happening in "adb logcat"? Also, what is going on
> in your web server logs?
>
> Simon Mac Donaldhttp://hi.im/simonmacdonald

jul...@prod-3d.com

unread,
Apr 18, 2012, 6:35:00 AM4/18/12
to phon...@googlegroups.com
Subscribing to Robert issue.

Wich is a duplicate from mine here : https://groups.google.com/forum/?fromgroups#!topic/phonegap/HEIiy5hh31w
Look like we're trying to do something wrong.
Can't seem to find what it is however.

jul...@prod-3d.com

unread,
Apr 18, 2012, 11:15:22 AM4/18/12
to phon...@googlegroups.com

Simon MacDonald

unread,
Apr 18, 2012, 2:08:08 PM4/18/12
to phon...@googlegroups.com
This is a bug, the library should be able to handle this case. I opened and fixed the issue for an upcoming release. 


I did a blog post with a work around and more details as how the bug slipped into 1.5.0.


and finally my apologies for having this bug sneak in. There was missing test coverage before the release but I've added some automated tests for this issue for future releases.

Simon Mac Donald
http://hi.im/simonmacdonald


--

Sergio Roberto de Almeida

unread,
Jun 26, 2013, 2:33:05 PM6/26/13
to phon...@googlegroups.com
Boa Tarde estou recebendo o mesmo erro: error code:3 , porém só recebo esse erro no ios, no android funciona normalmente, estou fazendo download de 40 imagens ou mais , porém da erros apenas em algumas imagens , as outras baixa normal, e não são sempre as mesmas imagens que dão erro, gostaria de saber o que eu poderia fazer?

Сергей Цыбульский

unread,
Oct 9, 2013, 5:32:02 AM10/9/13
to phon...@googlegroups.com
Guys try this - add code:
var op;
op = new FileUploadOptions();

op.headers = {
Connection: "close"
};

After adding this - code started to work well with no errors.
Hope that helps!

четверг, 29 марта 2012 г., 1:16:20 UTC+3 пользователь Mike написал:
Reply all
Reply to author
Forward
0 new messages