Apps-android-commons: Image downloading fails

Created on 27 Feb 2018  路  16Comments  路  Source: commons-app/apps-android-commons

Summary

Clicking the download button after going to My Recent Recent Uploads fails to download an image to the phone's storage even when the app has been granted Storage Permission.

Screenshots

whatsapp image 2018-02-27 at 9 09 05 am 2
whatsapp image 2018-02-27 at 9 02 21 am 2

System Logs

The log report can be found at this link:
Log Report File

Device and Android version

Redmi Note 3
6.0.1 MMB29M
MIUI Version: MIUI Global 8.5

Commons app version:
2.6.7

assigned bug

Most helpful comment

Please feel free to take up the issue. @gupta-meghna64 or @knight-shade.

All 16 comments

Yup @gupta-meghna64 , I can confirm the issue.

Device and Android Version
Android 7.0 MIUI Global V9.0

Can I take up this issue?

Let us wait for a confirmation @knight-shade

That's really weird but I confirm that I cannot download images either. ("Download Failed")

Please feel free to take up the issue. @gupta-meghna64 or @knight-shade.

I'd like to explore about the issue and work on it. I'll keep on updating my progress here :-)

@gupta-meghna64 didn't realised this issue was assigned to you, although this might be useful for you:

The following two options appear before you select the download one:

whatsapp image 2018-02-27 at 9 10 02 pm 2

The reason why all the downloads are unsuccessful is both the urls of the above options are different, just for example in case of image I uploaded:

View in Browser url :
https://commons.m.wikimedia.beta.wmflabs.org/wiki/File:Madhugiri_fort.jpg

Download url:
https://upload.beta.wmflabs.org/wikipedia/commons/6/64/File%3AMadhugiri_fort.jpg

The Download url is the one which leads to 404 error, hence obviously download being unsuccessful because there is no image existing at that url.

The correct download url should be:
https://upload.beta.wmflabs.org/wikipedia/commons/0/0c/Madhugiri_fort.jpg

The below picture lists the necessary changes( ~ just 2 lines), after which all downloads are successful.
solution

I have tested the solution on real device and attached a gif below illustrating successful download of image:
uploadsolution

@maskaravivek, @gupta-meghna64 AFAIK very likely 99% :) this problem is caused due to issue mentioned in #1169 .
Can you verify the same ?

Update
Base image url is not same for everybody, so the above solution won't work.

@knight-shade The base imageUrl that you have specified in the code as https://upload.beta.wmflabs.org/wikipedia/commons/0/0c/ isn't the same for every image being uploaded. In my case, the base url turns out to be
https://upload.beta.wmflabs.org/wikipedia/commons/b/bd/

So, I guess we'll have to find out an alternative way of fetching the base URL instead of hard-coding it.

@gupta-meghna64 , Uh ohh, I think it varies for each user, is it? can't verify this though. If it is dynamically generated then its more a backend problem then app. Better solution might be just make the backend much bettter. I think if this issue #1169 is solved then image failed issue might automatically gets solved as a side effect.

@knight-shade The URL generated in the case of images with no spaces in the name is perfect, and the downloading is also taking place. But the problem comes when the image that has been uploaded has a space/special symbol in the name because of which the imageURL being generated is incorrect.

@gupta-meghna64 I have come up with a fix, shortly will update in detail.
Update
In SingleUploadFragment in fuction onOptionsItemSelected (line 73), removing any special symbols first, and then replacing spaces with underscores solves this issue, and apparently should solve #1169 also.

image_failed_update_solution

I have tested this on real device, and works like a charm. Can you confirm the same?

@knight-shade It's working :-)

A few difficult file names to check:

  • File:膶SD 艡. M 260.001 1939-02.17. 24.jpg
  • File:丿賲卮賯 噩亘賱 賯丕爻賷賵賳.jpg

Does the regex work for them?

Currently the app crashes for filenames which are not in english, trying to work on the issue.

@gupta-meghna64 , @VojtechDostal
The below solution allows you to upload image with any title irrespective of whether it contains special symbos, spaces, or any language as far as I could check.

selection_002

Some example images with difficult names:
whatsapp image 2018-02-28 at 6 43 15 pm

And the images are downloading also, cheers :+1:

@knight-shade Since you've already figured out the solution, I request you to put a PR to this and @VojtechDostal and @maskaravivek to re-assign the issue to @knight-shade

@gupta-meghna64 , now again it will take more time to re-assign the task, its hardly a line, and since its already assigned to you, I request you to make the PR kindly. :ok_hand:

Was this page helpful?
0 / 5 - 0 ratings