apps-android-commons icon indicating copy to clipboard operation
apps-android-commons copied to clipboard

"Download unsuccessful" when downloading image from the app

Open nicolas-raoul opened this issue 3 months ago • 2 comments

https://github.com/user-attachments/assets/7fb9bf96-3a7e-4589-891e-ed423adb861f

https://github.com/user-attachments/assets/06e1e8cd-d881-4bb3-be40-451077ffa54a

nicolas-raoul avatar Aug 21 '26 01:08 nicolas-raoul

Hi! I'm a new contributor and I'd like to work on this issue. Could I please be assigned to it? I'd be happy to investigate the cause and submit a PR.

AdityaDarke97 avatar Sep 01 '26 04:09 AdityaDarke97

I managed to reproduce this and found the root cause It turns out the system's DownloadManager is being rate-limited by the Wikimedia/Cloudflare servers. Because the app wasn't setting a User-Agent header on the DownloadManager.Request, the system was sending a generic Android User-Agent. The server's bot-protection treats this as a bot and rejects the download with an HTTP 429 (Too Many Requests).

So what I did was add a new line in the request, which basically is a requestHeader with head User-Agent that tells the server that this request was from the original app.

addRequestHeader("User-Agent", "CommonsAndroidApp/$currentVersion (https://commons-app.github.io/)")

now I haven't yet raised a PR about this since I'm still testing for photos, I did try downloading multiple photos on different android versions (including the ones in the videos) and they all downloaded (multiple times aswell). Since this is my first issue, I want to make sure that I'm going in the right direction here

P.S: I did raise the PR after testing multiple images multiple times on multiple android versions

AdityaDarke97 avatar Sep 01 '26 21:09 AdityaDarke97