monsieurbiz / SyliusRichEditorPlugin

This plugin add a rich editor on fields to be able to drag and drop elements and edit it.
MIT License
66 stars 38 forks source link

Unable to Upload Images to AWS S3 Bucket Using Rich Editor Plugin #205

Open yassine20011 opened 1 year ago

yassine20011 commented 1 year ago

Hello, I use the Rich Editor plugin for specific sections on my website. However, I'm facing an issue where images are only uploaded to the public folder instead of my AWS S3 bucket. I've ensured that my AWS configuration is correct because I can successfully upload images on pages that do not utilize the Rich Editor plugin.

Here's a snippet from my monsieurbiz_sylius_rich_editor_plugin.yaml:

knp_gaufrette:
    adapters:
        sylius_image:
            aws_s3:
                service_id: acme.aws_s3.client
                bucket_name: "%aws_s3_bucket%"
                detect_content_type: true
                options:
                    create: true
                    directory: "media/image"
                    acl: "private"
        monsieurbiz_rich_editor_fixture_file:
            aws_s3:
                service_id: 'acme.aws_s3.client'
                bucket_name: '%aws_s3_bucket%'
                detect_content_type: true
                options:
                    create: true
                    directory: '/media/image'
                    acl: 'private'
    filesystems:
         sylius_image:
            adapter: sylius_image
        monsieurbiz_rich_editor_fixture_file:
            adapter: 'monsieurbiz_rich_editor_fixture_file'

monsieurbiz_sylius_richeditor:
    upload_directory: '/media/image'
    image_upload_directory: '/media/image'
    ui_elements:
        sections.hero:
            alias: hero
            title: 'Hero'
            description: 'Hero'
            icon: html5
            tags: [default]
            classes:
                form: App\Form\UiElement\HeroType
            templates:
                admin_render: 'bundles/SyliusAdminBundle/UiElement/hero.html.twig'
                front_render: '@MonsieurBizSyliusRichEditorPlugin/Shop/UiElement/html.html.twig'

Here' my config\services.yaml:

    env(AWS_ACCESS_KEY_ID): ""
    env(AWS_SECRET_ACCESS_KEY): ""
    env(AWS_BUCKET_NAME): ""
    env(AWS_REGION): ""
    aws_s3_key: "%env(AWS_ACCESS_KEY_ID)%"
    aws_s3_secret: "%env(AWS_SECRET_ACCESS_KEY)%"
    aws_s3_bucket: "%env(AWS_BUCKET_NAME)%"
    aws_s3_region: "%env(AWS_REGION)%"
    aws_s3_version: "2006-03-01"

services:
    # Default configuration for services in *this* file
    monolog.logger.paypal: '@logger'
    acme.aws_s3.client:
        class: Aws\S3\S3Client
        factory: [ Aws\S3\S3Client, 'factory' ]
        arguments:
            -
                version: "%aws_s3_version%"
                region: "%aws_s3_region%"
                credentials: { key: "%aws_s3_key%", secret: "%aws_s3_secret%" }
    acme.imagine.cache.resolver.aws_s3_resolver:
        class: Liip\ImagineBundle\Imagine\Cache\Resolver\AwsS3Resolver
        arguments:
            - "@acme.aws_s3.client"
            - "%aws_s3_bucket%"
            - "private"
            - { Scheme: https }
        tags:
            - { name: "liip_imagine.cache.resolver", resolver: "aws_s3" }

It seems that I have configured my YAML file to upload images to my AWS S3 bucket, but it's not working as expected. Any guidance or assistance on resolving this issue would be greatly appreciated.

Thank you!