kcal-app / kcal

the personal food nutrition journal
Mozilla Public License 2.0
295 stars 27 forks source link

Recipe image doesn't show #33

Closed RyderForReal closed 3 years ago

RyderForReal commented 3 years ago

After uploading a recipe image, it does not show up and instead 404s (when accessing my installation via its local IP) or straight up doesn't display without any errors (when accessing my installation via the url defined in .env).

cdubz commented 3 years ago

Assuming you’re using the default (local disk) for media — do you see any files in the public/media directory (from the app root)? I wonder if there is some permissions configuration that is not addressed there for the manual install.

RyderForReal commented 3 years ago

I do. The uploaded image is in a subfolder of that folder as well. I'll try to chmod 777 the whole directory to exclude permission issues.

RyderForReal commented 3 years ago

Nope. chmodded the directory (recursively, obviously) to 777 and still nothing. I'm not even getting an error now.. Although when uploading the image, it gives me a 404 for the preview: GET https://[domain]/media/7/conversions/[etc] 404

RyderForReal commented 3 years ago

Tried uploading a profile picture to see if it's a general issue - that 404ed as well. GET https://[domain]/media/8/conversions/ryderfornow-icon.jpg 404

cdubz commented 3 years ago

Curious — and you said the originals are being uploaded? But the conversions are missing?

RyderForReal commented 3 years ago

Yes, it seems like it.

RyderForReal commented 3 years ago

I can access the unconverted upload without any issues. But the conversion does not exist (neither on the filesystem nor on the site)

cdubz commented 3 years ago

Hm ok. I wonder if there is a dependency missing from the manual install instructions for the media handling. What base system (Debian, Ubuntu, etc.) and version are you using?

RyderForReal commented 3 years ago

Ubuntu (server) 20.04

cdubz commented 3 years ago

Ok I’ll try to find some time today to test from that base and see if something is missing.

In the mean time you may be able to troubleshoot by poking around the docs for the library that handles these conversions — https://spatie.be/docs/laravel-medialibrary/v9/requirements

I’m guessing a PHP module or image library is missed somewhere in the install steps.

cdubz commented 3 years ago

@RyderForReal a couple of things are probably happening here --

  1. By default, the media conversions are queued. This seems unnecessary for an app like this so I have changed the example .env file to handle conversions immediately instead of in queue. Add the following to your .env to do the same:

    QUEUE_CONVERSIONS_BY_DEFAULT=false

  2. The temp directory used by the media conversion library may not have correct permissions. To check them try:

    ls -lah {APP_ROOT}storage/media-library/

    There should be a temp directory in there with permissions drwxrwxr-x and uid:gid $USER:www-data. If the directory has some other permissions, see below and use those commands.

I also added a step to the manual install process to try to address this directly, but it may need more testing. As a final step the documentation now has:

1. Allow web server to access required directories.

       sudo chown -R $USER:www-data {storage,public}
       sudo chmod g+s {storage,public}

Let me know if any of that gets you going!

RyderForReal commented 3 years ago

Works! Thanks a lot.

cdubz commented 3 years ago

Nice! Eventually I need to come up with a way to simplify the permissions stuff for that manual install process…