dustin10 / VichUploaderBundle

A simple Symfony bundle to ease file uploads with ORM entities and ODM documents.
MIT License
1.83k stars 519 forks source link

Document how to get s3 URL #1434

Closed tacman closed 4 months ago

tacman commented 6 months ago
Q A
Bundle version latest
Symfony version 6.4 ^7
PHP version 8.3

I've configured the this bundle with the Flysystem s3 adapter, and it's working as expected when uploading.

The documentation for generating URLs says that it's relative to the local public directory, but if the adapter is s3 there is no local directory.

https://github.com/dustin10/VichUploaderBundle/blob/master/docs/generating_urls.md

Ultimately I'll want go to through liip/imagine-bundle, but for now I thought I'd start with the s3 url.

Is there documentation or a demo program for uploading to s3 and then displaying the images (and thumbnails)? I assume this is a pretty common setup.

Possibly related to #221 and #1424

Thanks for this bundle!

tacman commented 6 months ago

For now, I've put the bucket path in the config, but this will only work for public images

    mappings:
        submissions:
            upload_destination: default.storage # Use the name you defined for your storage here
            uri_prefix: https://%env(AWS_S3_BUCKET_NAME)%.s3.us-east-2.amazonaws.com
            namer: Vich\UploaderBundle\Naming\SmartUniqueNamer
sovetski commented 5 months ago

Hi, I have the same issue here with another adapter: https://github.com/softavis/flysystem-cloudflare

In my case it is impossible to add uri_prefix manually, because in Cloudflare, the file name is not at the end, it is something like https://imagedelivery.net/qsdazd54azd98a4z69d5/image3.jpg/public the /public at the end makes it impossible because it is not just a prefix, we have to do some sprintf etc.

Is it normal that VichUploaderBundle does not handle it? How we can resolve this problem?

Thanks in advance