SyliusCmsPlugin
SyliusCmsPlugin copied to clipboard
Using (fully) KnpGaufrette to provide an abstraction for files uploading/reading
Hi, :wave: First, let me thank you for the plugin. We are planning to use Sylius for creating new ecommerce websites for our customers, and the "CMS feature" was definitely missing from Sylius.. so thanks! :)
We are still in the testing phase and we faced an issue with the plugin and the way used for uploading/reading files.
For some context, I configured Sylius to upload files to a S3 bucket (Scaleway) by using this configuration:
# config/packages/knp_gaufrette.yaml
knp_gaufrette:
adapters:
sylius_image:
aws_s3:
service_id: Aws\S3\S3Client
bucket_name: '%aws.s3.bucket%'
detect_content_type: true
options:
directory: '%env(AWS_S3_PREFIX)%/media/image'
acl: 'public-read'
stream_wrapper: ~
# config/packages/liip_imagine.yaml
liip_imagine:
loaders:
aws_s3:
stream:
wrapper: gaufrette://sylius_image/
resolvers:
aws_s3:
aws_s3:
# By doing this, we won't let LiipImagineBundle create another S3Client instance instead of re-using the existing one.
# The service "liip_imagine.cache.resolver.aws_s3.client" must be defined manually.
client_config: ~
bucket: '%aws.s3.bucket%'
get_options:
Scheme: https
put_options:
CacheControl: 'max-age=86400'
cache_prefix: '%env(AWS_S3_PREFIX)%/media/cache'
data_loader: aws_s3
cache: aws_s3
and it works fine (e.g.: uploading a photo for a product).
However, this does not work with the plugin. When you upload an image through CKEditor (provided by the plugin), the file will be saved the disk where the project lives (e.g.: /.../public/media/...
).
I've read the code and trying to understand how to change that, and I found a parameter bitbag_sylius_cms_plugin.uploader.filesystem
.
I changed its value to my Gaufrette adapter sylius_image
, this way the service bitbag_sylius_cms_plugin.media.filesystem
(used by service bitbag_sylius_cms_plugin.media_uploader
, then used by service bitbag_sylius_cms_plugin.media_provider.image
) will upload images to S3, but this does not work:
But the file is not uploaded anymore (not on the filesystem nor on S3), and the upload action returns a media path that does not exists:
Before investigating more, I've also found that \BitBag\SyliusCmsPlugin\Controller\PageController::resolveImage
is using the filesystem to get the file, not Gaufrette's Flysystem, making it unusable when medias should can't be stored in the public directory:
Do you know if fully Gaufrette support is planned, and if we can easily implement it?
Thanks!
Hi,
Up ! Please provide a fully support for external filesystem.
Thx.