3
votes

i am using the s3 provider for the sonata media bundle. The AWS S3 storage is a static bucket with a subfolder:

s3://bucketname/subfolder

How can i access this subfolder with the sonata media bundle? Here is my config:

sonata_media:
default_context: default
db_driver: doctrine_orm
providers:
  image:
      filesystem:         sonata.media.filesystem.s3
      allowed_extensions: ['jpg', 'png', 'gif', 'jpeg']
      allowed_mime_types: ['image/pjpeg','image/jpeg','image/png','image/x-png', 'image/gif']
contexts:
    default:  # the default context is mandatory
        download:
            strategy: sonata.media.security.public_strategy
            mode: http

        providers:
            - sonata.media.provider.image

cdn:
    server:
        path: http://%bucket_name%.s3.amazonaws.com/subfolder

filesystem:
    local:
        directory:  %kernel.root_dir%/../web/uploads/media
        create:     false
    s3:
        bucket: %aws_bucket_name%
        accessKey: %aws_access_key%
        secretKey: %aws_secret_key%
        create: false
        region:
        storage: standard
        acl: public 

Where can i set the subdirectory "subfolder"? Because currently i get the following error:

Failed to determine HOME directory after trying "cd: 1: can't cd to ~" (exit code 2), referer: http://nutella-fb-app.nadine.dresden.rsm-service.de/app_dev.php/admin/sonata/media/media/create?provider=sonata.media.provider.image&context=default

when i upload an image.

Additional question: How can i display the images in the frontend?

Thanks for your feedback.

1

1 Answers

1
votes

We have found the solution:

There is another option for the s3 provider, where you can set a subdirectory:

filesystem:
    s3:
        bucket: %aws_bucket_name%
        accessKey: %aws_access_key%
        secretKey: %aws_secret_key%
        create: false
        region:
        storage: standard
        directory: subfolder