Ansel in conjuction with S3 via Treasury doesn't return the image url
#111 opened by Ignite
Description
We are using Ansel for image cropping and recently purchased Treasury for migrating the storage to S3. Even though the Treasury locations are set correctly and communication between Ansel and S3 is clearly happening (images get uploaded, thumbnails/cropped versions are getting generated and pushed to the respective bucket sub-directories), the Ansel {img:url} tag doesn't return a proper value.
We tried two configurations with slightly different results:
- When Upload directory and Save directory are set to the same Treasury S3 location, {img:url} returns the path of the S3 location without the image specific relative path.
- When Upload directory and Save directory are different Treasury S3 locations, {img:url} and {img:path} return empty string, {img:filesize} and {img:file_id} are both 0.
In both cases {img:thumbnail_path} and {img:thumbnail_url} are returning correct relative path to the cropped image, so it's possible to sticth a correct URL with some custom code by combining values from differernt tags but not going through the {img:ulr} tag strips all of the usefulness of Ansel which defeats it's purpose.
Replies
- TJ Draper
Replied 6/30/2018 12:12 PM, Edited 11/10/2018 9:48 AM
I'm really sorry, I know it's frustrating to hear this, but I haven't been able to replicate this issue. I feel like there must be something environmental going on and I will probably need to get access to your environment to see if I can figure out what's going on.
- Ignite
Replied 7/2/2018 8:34 AM, Edited 11/10/2018 9:48 AM
Hello TJ,
After some additional research and tests it turns out that the issue only appears locally while everything works as expected on the non-local environments. The obvious only difference I can see at the moment is that locally we don't use https while the other 2 servers which work do. Could that affect the underlying logic in some way?
- TJ Draper
Replied 7/2/2018 9:22 AM, Edited 11/10/2018 9:48 AM
I can't see how SSL present or not could affect that code. I was not using SSL in my local test environment.
- Ignite
Replied 7/2/2018 12:59 PM, Edited 11/10/2018 9:48 AM
Hey TJ,
I believe I've narrowed it down a lot further. We are developing locally using a Docker Ubuntu 16 container and the issue seems to be affecting only Windows-based hosts.
The save method in SaveRow.php copies the processed image a few times while doing manipulations to it. The copy destination is always the exact same filename which is created and then deleted before the next step starts. Under the specific conditions mentioned above the second copy fails even though the destination file is deleted prior which results in a broken chain of events and ultimately the incomplete result of the tag. I'm not sure exactly what is causing the issue but changing the different destination names prevents it from happening while achieving the same result (the filenames seem to be unimportant as all data is taken from them and at the end of each step the respective copy is deleted anyway).
Maybe this will help out pinpointing some weird quirk.
- TJ Draper
Replied 7/2/2018 1:01 PM, Edited 11/10/2018 9:48 AM
Ahh, okay, I have run into an issue like this on an unrelated site/software. It seems like with Docker on Windows sometimes the file system can't keep up and throws weird errors. Although I was testing your issue with Docker on Windows and didn't run into it. I also have a very fast SSD and I wonder if it might have something to do with slower disks...
- TJ Draper
Replied 7/2/2018 1:02 PM, Edited 11/10/2018 9:48 AM
Ahh, crud, I'm sorry, I wasn't using Docker. Ansel 2 is still using my older Vagrant environment.