craftcms / aws-s3

Amazon S3 volume type for Craft CMS.
https://plugins.craftcms.com/aws-s3
MIT License
61 stars 28 forks source link

[v3.x] Leveraging the new Subpath option within a volume in Craft 5 causes Rekognition to return a 400 error #173

Closed kylecotter closed 8 months ago

kylecotter commented 9 months ago

Description

A filesystem with Attempt to set the focal point automatically? enabled, a subfolder set, and a Volume leveraging this filesystem with a subfolder set, results in the Rekognition api returning a 400 Unable to get object metadata from S3

Not leveraging a subfolder in the volume prevents the error.

Specifically, I have a filesystem named Cloud Provider. The subfolder of this filesystem is @s3BasePath which is an alias of a path that gets set based on the environment we're working in.

I have 2 volumes. One named Uploads and one named User Photos. Both volumes use the Cloud Provider filesystem. Both volumes set their subpath to uploads and users respectively. When uploading a user photo, the error occurs.

If however, I remove the subpath from the volumes, and setup two bespoke filesystems (how we would in Craft 4) for their corresponding volume, this issue does not occur.

Steps to reproduce

  1. Create a filesystem with a subfolder path. e.g @s3BasePath
  2. Enable Attempt to set the focal point automatically?
  3. Create a volume using this new filesytem
  4. Set the subpath of the volume to foobar
  5. Save the volume
  6. Upload an image via the CP
  7. Get 400 error toast notification

Additional info

brandonkelly commented 8 months ago

This should be fixed in v2.1.0, which supports both Craft 4 and 5. You can change your craftcms/aws-s3 requirement to ^2.1.0 and run composer update to get it.

kylecotter commented 8 months ago

@brandonkelly Was still hitting this issue after updating.

Pretty sure the $filesystem subfolder path should come first before the volume path here.

brandonkelly commented 8 months ago

@kylecotter Doh, you’re right. Just fixed and tagged 2.2.1.