问题描述:

Hi Stackoverflowianers!

It's me again, having a PhoneGap question:

Working on PhoneGap 2.8.1 I made a file download working by the fileTransfer.download() method. Seams to work like a charm but all files (no metter what size or extension) are downloaded to 6 kilobyte files. Source and target is ok as far as I can see but the download ends regularly after 6 kilobytes. No error, no nothing...

My code:

 navigator.notification.activityStart("Please wait....", "Loading");

var fileTransfer = new FileTransfer();

var uri = $(this).attr('file');

var fName = uri.substring(uri.lastIndexOf('/')+1);

var localPath = '/mnt/sdcard/download/';

var filePath = localPath+fName;

fileTransfer.download(

uri,

filePath,

function(entry) {

navigator.notification.activityStop();

navigator.notification.alert('/sdcard/download/', function(){}, 'Saved in...', 'Close');

console.log("download complete: " + entry.fullPath);

},

function(error) {

navigator.notification.alert('Code: '+error.code, function(){}, 'Error...', 'Close');

console.log("download error source " + error.source);

console.log("download error target " + error.target);

console.log("upload error code" + error.code);

}

);

Have anybody had this problem before? Does anybody have a glue what could be the reason for this misbehaviour???

I'd be very happy for some - or at least one - hint to the right direction...!

Thnx. in advance for your reply.

Ingmar

网友答案:

Sorry to all Stackoverflowianers!!! I solved it my self...

But enyway, if you ever run into this just get the idea here to help your self:

"Just copy the downloaded 6 kilobyt (or more or less) file from your device to the PC and - e.g. with Notepad++ - have a look what is in there. The content of the file will help you directly to solve your problem..."

Greatinx,

Ingmar

相关阅读:
Top