spacecatninja / craft-imager-x

Image transforms, optimizations and manipulations for your Craft CMS site.
Other
26 stars 16 forks source link

Transformed Images not uploading in the AWS S3 bucket #258

Closed Brijeshgrg1999 closed 8 months ago

Brijeshgrg1999 commented 8 months ago

I'm submitting a...

Steps to reproduce

1.Setup AWS storage option in imager-x.php config
2.Set up and load a page using craft.imager.transformImage

Description

I have set up an AWS S3 bucket and CloudFront for asset storage in Craft CMS, and normal assets can be uploaded through the CMS without any issues. However, when I try to use Imager-X to transform images and store them in the S3 bucket according to this article : https://imager-x.spacecat.ninja/usage/external-storages.html , but I can't see any transformed images in the bucket. Is there anything i am missing ?

Here's my imager-x.php configuration file:


<?php
return [
  'imagerUrl' => 'https://d1ef7ke0x2i9g8.cloudfront.net/Singapore-Transformed-Assets/', 
  'storages' => ['aws'], 
  'storageConfig' => [
    'aws' => [
      'accessKey' => getenv('S3_KEY_ID'),
      'secretAccessKey' => getenv('S3_SECRET'),
      'region' => getenv('S3_REGION'),
      'bucket' => getenv('S3_BUCKET'),
      'folder' => 'Singapore-Transformed-Assets',
      'requestHeaders' => array(),
      'storageType' => 'standard',
      'public' => false,
      'cloudfrontInvalidateEnabled' => true,
      'cloudfrontDistributionId' => getenv('CLOUDFRONT_DISTRIBUTION_ID'),
    ],
  ]
];
?>

### Additional info

  - Imager version & edition: 4.3.1 free version 
  - Imager transformer: craft 
  - Craft version: 4.5.10
  - PHP version: 8.1
aelvan commented 8 months ago

Hi,

Have you checked your logs and/or the debug toolbar?

Did you clear the imager cache (ie emptied imagerSystemPath) after configuring the external storage? If the transformed file exists in the system path, it will not be uploaded to external storages.

Did you check in the AWS console that the transforms were not uploaded anywhere in the bucket (ie, maybe they got uploaded somewhere else in the bucket other that Singapore-Transformed-Assets due to an error)?

Brijeshgrg1999 commented 8 months ago

thanks for the reply , I checked the logs , it seems I am on the free version of the imager-x and also I am testing on staging , so that was the issue I believe.

aelvan commented 8 months ago

Right, you need to upgrade to pro to use external storages. Can still trial it for free though. :)

Brijeshgrg1999 commented 8 months ago

cheerss

Brijeshgrg1999 commented 8 months ago

@aelvan sorry I am actually facing some issue , I want to remove to remove the Transformed images after it gets upload on the AWS S3 , so that I added " { removeTransformedFilesOnUpload' => true } in the imager-x.php . But I still see those transformed file on my " imagerSystemPath " . Is there a way to actually solve this issue ? . FYI I can see the assets on my s3 bucket.

aelvan commented 8 months ago

This is the expected behaviour, Imager uses the transforms in the imagerSystemPath as the primary cache, the external storage is just an additional place the transforms are stored.

(and removeTransformedFilesOnUpload isn't a valid config setting, unsure where you found that?)

Brijeshgrg1999 commented 8 months ago

so the primary cache will be there forever ?