Piwigo / Piwigo-Android

Piwigo Native Android App
GNU General Public License v3.0
141 stars 43 forks source link

Uploaded images don't have file extension in `file` column of piwigo_images table #175

Closed nkinkade closed 4 years ago

nkinkade commented 4 years ago

Describe the bug and how to reproduce Let me start by saying that this seems like such a large bug that I'm surprised it's not already reported and/or fixed, which leads me to be suspicious that it's something about my environment and not necessarily a bug in the Piwigo Android code. That said, I don't know where else to report this, since I'm using an unmodified version of Piwigo 2.10.1 with standard features, etc.

  1. Upload a file from your Android device to your Piwigo instance.
  2. The image is uploaded, and thumbnail appears on the main photo page, but when you click the thumbnail you get a 404 and "The requested image does not exist."

Expected behavior I expect the images to be displayed, and not receive a 404.

What did you do already I've discovered why the problem is occurring, but not what the source of the problem is.

The URL that the broken thumbnail points to is something like:

https://example.com/picture/myimage/category/3

The query that gets executed on the server is something like:

SELECT id, file, level FROM piwigo_images WHERE file LIKE 'myimage.%' ESCAPE '/' LIMIT 1

... which returns 0 rows because the actual value of the field file in the database is myimage. Notice the .% at the end of the query for the field. Since the actual value of the file field has no extension, it fails to find it. Apparently Piwigo expects that every value in file column of the piwigo images table will have an extension of some sort.

So this is the proximate cause of this issue, but what I don't yet know is whether Piwigo Android is doing everything right and this is possibly some bug in the Piwigo API, or if the Android app is not sending quite the correct data to Piwigo.

Smartphone:

Additional context

Depending on your display size, click on any of the images in the 2nd row of images (e.g., the one with the baby with a dirty face eating a pork chop):

@voriondev -> (Removed gallery link for privacy reasons)

ramack commented 4 years ago

Thanks for reporting especially with all those details it helps a lot.

You can try to change your piwigo-server config from $conf['picture_url_style'] = 'file'; to $conf['picture_url_style'] = 'id-file'; as a workaround. (See also https://github.com/Piwigo/Piwigo/issues/362 for some more details.)

In the APP we should

nkinkade commented 4 years ago

Thank you, @ramack. Your workaround works as expected. Thank you also for your work on this Android app, which is immensely useful for getting images from our mobile devices directly into our Piwigo instance.