image-resizer icon indicating copy to clipboard operation
image-resizer copied to clipboard

When uploading an image with a filename that already exists, and chosing "rename", image-resizer errors

Open jamie-s-white opened this issue 1 year ago • 14 comments

Describe the bug

When uploading an image with a filename that already exists, and chosing "rename", image-resizer errors

Steps to reproduce

  1. Upload a file named "test-image-6.jpg", image-resizer correctly handles the file
  2. Upload a second file named "test-image-6.jpg".
  3. Choose "rename" when Craft CMS asks
  4. Image-resizer has not resized this image
  5. In the logs, we have: error Error. Unable to find path: Screenshot 2023-09-12 at 15 06 40

Craft CMS version

3.7.16

Plugin version

2.2.1

Multi-site?

No

Additional context

No response

jamie-s-white avatar Sep 12 '23 14:09 jamie-s-white

Are you able to confirm what volume filesystem you're using? Local, S3 or other?

engram-design avatar Sep 13 '23 07:09 engram-design

S3

jamie-s-white avatar Sep 13 '23 07:09 jamie-s-white

This also happens when I just click save on an image that has already been uploaded.

I have done a bit of additional debugging on this, and I can see in:

src/services/Service.php

We have:

    public function beforeHandleAssetFile(AssetEvent $event)
    {
        $asset = $event->sender;
        $filename = $asset->filename;
        $path = $asset->tempFilePath;

When this bug occurs, $asset->tempFilePath is NULL.

Evidently it has other file information, such as $asset->filename, which is correctly set.

When we upload a fresh file, $path returns:

/var/www/example.com/releases/63/storage/runtime/temp/rc365084d3fe1c347.79901316.jpg

jamie-s-white avatar Sep 18 '23 13:09 jamie-s-white

Should be fixed for the next release. To get this early, run composer require verbb/image-resizer:"dev-craft-3 as 2.2.1".

engram-design avatar Sep 19 '23 01:09 engram-design

Hi,

Now when we save a file, we get the error:

Could not open create the stream for “test.jpg”

(Where test.jpg is the name of the file).

From line 200 of vendor/craftcms/cms/src/base/FlysystemVolume.php

jamie-s-white avatar Sep 19 '23 07:09 jamie-s-white

Hmm, so that must be a result of $asset->getImageTransformSourcePath() which is supposed fetch the local copy of the asset for remote volumes. Can I ask what your S3 volume settings are?

engram-design avatar Sep 19 '23 13:09 engram-design

Name: Files Handle: Files Assets in this volume have public URLs: true Subfolder: None Make uploads public: true Attempt to set the focal point automatically?: False Cache duration: 1 day CloudFront Distribution ID: Set CloudFront Path Prefix: Not set

Please let me know if you need any more information

jamie-s-white avatar Sep 19 '23 14:09 jamie-s-white

Looks identical to mine! I'll keep digging to try and replicate this.

engram-design avatar Sep 21 '23 06:09 engram-design

Let me know if admin access to our staging environment might help, and I'll see if I can get that.

Also keep in mind that we are on Craft 3.7.16, in case that makes a difference. I'm not sure this client has the budget to update to the latest 3.9.x version. We are however using the latest version of the craftcms/aws-s3 plugin.

jamie-s-white avatar Sep 21 '23 09:09 jamie-s-white

That might be useful, and best to get in touch via [email protected]. I have been testing on Craft 3.9 as I wasn't under the impression it'd make a difference as there haven't been massive changes between those. But I'll spin up a site just in case.

engram-design avatar Sep 21 '23 13:09 engram-design

Thank you! I have put in a request to grant you access, but we won't get that until next week. I will reach out to [email protected] when I know more.

jamie-s-white avatar Sep 22 '23 08:09 jamie-s-white

I have now been pulled from this job due to lack of budget to take this further forward, so I will not be able to assist any further with this bug report. We have decided to resize the images manually instead of using this plugin, apologies.

jamie-s-white avatar Sep 25 '23 14:09 jamie-s-white

I will also add that we are seeing this issue on at least one other of our projects however, and whenever we see the issue, we get the same result:

Could not open create the stream for “test.jpg”

jamie-s-white avatar Sep 25 '23 14:09 jamie-s-white

Thanks for the update, and sorry we haven't been able to get to the bottom of it. I'll keep at it on my end. I did test out on Craft 3.7 specifically, just in case that was a factor, but wasn't able to reproduce it.

engram-design avatar Sep 25 '23 23:09 engram-design