apache / cordova-plugin-file-transfer

Apache Cordova File Transfer Plugin
https://cordova.apache.org/
Apache License 2.0
596 stars 887 forks source link

[Android] Handle redirects when downloading a file #126

Closed restouffer closed 6 years ago

restouffer commented 8 years ago

The FileTransfer plugin was stopping on a 301 redirect and storing the HTML from that page instead of the target file. This adds a loop that detects redirect headers and continues following them until a non-redirect page is loaded.

Based on the work of mathieudutour: https://github.com/phonegap/phonegap-plugin-contentsync/pull/95

abarranco commented 8 years ago

I've been 2 days debugging my project when i figured out that this was actually a problem. When i tried to download images from http with 301 response, file transfer downloaded that response and not followed the new url to get the final resource via https. Exactly what restouffer says. I think the plugin should allow to download the real resource. I am thinking this could be a security issue as well??. The url suggested in the 301 response will go trought the whitelist plugin?

ghenry22 commented 8 years ago

I have also hit this problem and it causes ongoing issues for my app. Could this be checked and merged soon?

MartoYankov commented 8 years ago

I encountered the same problem. restouffer's branch fixes the issue. It's vital that this gets merged soon since usually we don't have power over the backend to remove the redirect.

cordova-qa commented 8 years ago

Cordova CI Build has one or more failures.

Commit - Link Dashboard - Link

Builder Name Console Output Test Report Device Logs
Windows 8.1 Store Link Link Link
Windows 8.1 Phone Link Link Link
iOS Link Link Link
Android Mac Link Link Link
restouffer commented 8 years ago

I'm not familiar with Jenkins, but I'm not convinced those links suggest this patch is the cause of the CI failures. This patch is Build #10 out of 11. Build 9 has 75 failures while 10 has 59, which could mean this patch fixes 16 errors from the earlier builds. If there is a problem with the patch I would be more than happy to try fixing it, but I'll need more details.

According to Jenkins:

Build Errors
 #1     0
 #2     0
 #3     0
 #4    72
 #5    75
 #6    77
 #7    77
 #8    77
 #9    75
#10    59
#11    77
Pazkov commented 8 years ago

Please merge...

maverickmishra commented 6 years ago

With the new features introduced in XMLHttpRequest, this plugin is not needed any more. Migrating from this plugin to using the new features of XMLHttpRequest, is explained in this Cordova blog post.