benjaminmwilson / cordova-plugin-downloader

Cordova Downloader Plugin with no cordova-file-transfer dependency
Apache License 2.0
9 stars 7 forks source link

Downloaded file (application/octet-stream) is of 0 bytes. #6

Closed mashrurbd closed 3 years ago

mashrurbd commented 3 years ago

Dear Concern,

I am using your plugin, it works well on images with direct link. However, when I am trying to download a image file or a file having mime type of 'application/octate-stream' , the file is created, but not downloaded. It is showing 0 bytes as its file size.

The file I was trying to download: https://firebasestorage.googleapis.com/v0/b/brilliant-inferno-7571.appspot.com/o/albums%2Fprofile_photos%2F1602636386448?alt=media&token=e810cd88-faf1-4d99-86da-34e9daef74b0 (Didn't work)

But this file was downloaded perfectly: https://www.google.com.bd/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png

Please assist me to get rid of this issue.

Thanks in advance!

benjaminmwilson commented 3 years ago

Hello,

I'm not actively developing the plugin anymore but if I had to guess it's the GetLastPath() call at https://github.com/benjaminmwilson/cordova-plugin-downloader/blob/master/www/download.js#L94

It tries to use everything after the last / as the filename but in this case it would be albums%2Fprofile_photos%2F1602636386448?alt=media&token=e810cd88-faf1-4d99-86da-34e9daef74b0 which I think would definitely mess it up.

One way to verify this would be to change that piece of download.js so that it hardcodes the filename - say photo.png. If it works, then try hashing the albums%2Fprofile_photos%2F1602636386448?alt=media&token=e810cd88-faf1-4d99-86da-34e9daef74b0 part to an alphanumeric string so that there is no weird characters in there.

Also are there any error messages in the cordova console or adb logs?