statamic / cms

The core Laravel CMS Composer package
https://statamic.com
Other
4.13k stars 542 forks source link

Image manipulation doesn't work when you are using cloud storage in headless mode. #6648

Open saqueib opened 2 years ago

saqueib commented 2 years ago

Bug description

I have set following config in asset

// config/statamic/assets.php

'route' => 'img',
'secure' => false,
'cache' => true,
'cache_path' => public_path('img') 

And I am using google cloud storage, when I tried resizing image from url params its not working

https://storage.googleapis.com/bucket-name/some-headshot.jpg?w=400
https://statamic.test/img/some-headshot.jpg?w=400
https://statamic.test/img/asset::some-headshot.jpg?w=400

It works when you are using local disk for storage

How to reproduce

'route' => 'img', 'secure' => false, 'cache' => true, 'cache_path' => public_path('img')

- Try manipulating image using url with query params like `?w=200`
- It wont resize it

### Logs

_No response_

### Environment

```yaml
Statamic 3.3.32 Pro
Laravel 9.17.0
PHP 8.1.0

Installation

Fresh statamic/statamic site via CLI

Antlers Parser

regex (default)

Additional details

No response

lloydowen commented 1 year ago

Can also confirm all /img URL's seem to 404 when using CDN as the cache for Glide.

For example in config/statamic/assets.php i have 'cache' => 'glide' which is an S3 Store.

This works fine,

If i change that to false and request an asset such as:

Note the encoded string is just a base64 encoded version of the asset path.

http://127.0.0.1/img/asset/YXNzZXRzL2Jsb2ctZXZlbnRzL25ldy1oZXJvLWJhbm5lcnMtMDEyLmpwZw==?p=2xl-webp

I get an output.

If i change that back to S3 cache, that same URL returns a 404.

My only second thoughts are i'm not sure if the S3/CloudFront would need a rule to push /img requests back to the Statamic app?