Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jamie-s-white opened this issue Sep 12, 2023 · 14 comments

Comments

@jamie-s-white
Copy link

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

@engram-design
Copy link
Member

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

@jamie-s-white
Copy link
Author

S3

@jamie-s-white
Copy link
Author

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

@engram-design
Copy link
Member

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

@jamie-s-white
Copy link
Author

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

@engram-design
Copy link
Member

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?

@jamie-s-white
Copy link
Author

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

@engram-design
Copy link
Member

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

@jamie-s-white
Copy link
Author

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.

@engram-design
Copy link
Member

engram-design commented Sep 21, 2023

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.

@jamie-s-white
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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”

@engram-design
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants