I have a functional symfony application with sonata media. Till now, I was using the filesystem. But the uploaded files are getting bigger and bigger and I'm willing to use a CDN to store these files (to avoid memory allocation issues).
I went there but this config fails. I have a working cloudfront distribution but the option "cloudfront" is not recognized under sonata_media in config.yml.
Then, I tried and used a S3 bucket. Configuration looks OK but after I submit my upload form in sonata_admin, I get an error message : "can't write the key"...
My IAM user has full s3 acccess and the bucket is public.
Here comes my config :
sonata_media:
db_driver: doctrine_orm
class:
media: Application\Sonata\MediaBundle\Entity\Media
gallery: Application\Sonata\MediaBundle\Entity\Gallery
gallery_has_media: Application\Sonata\MediaBundle\Entity\GalleryHasMedia Application\Sonata\ClassificationBundle\Entity\Category
default_context: default
db_driver: doctrine_orm # or doctrine_mongodb, doctrine_phpcr
providers:
# allowed_mime_types: ['application/pdf', 'application/x-pdf', 'application/rtf', 'text/html', 'text/rtf', 'text/plain', 'video/mp4']
file:
service: sonata.media.provider.file
resizer: false
filesystem: sonata.media.filesystem.local
cdn: sonata.media.cdn.cloudront
generator: sonata.media.generator.default
thumbnail: sonata.media.thumbnail.format
allowed_extensions: ['pdf', 'txt', 'rtf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pttx', 'odt', 'odg', 'odp', 'ods', 'odc', 'odf', 'odb', 'csv', 'xml', 'mp4']
allowed_mime_types: ['application/pdf', 'application/x-pdf', 'application/rtf', 'text/html', 'text/rtf', 'text/plain', 'video/mp4', 'video/webm']
image:
service: sonata.media.provider.image
resizer: sonata.media.resizer.simple # sonata.media.resizer.square
filesystem: sonata.media.filesystem.s3
cdn: sonata.media.cdn.server
generator: sonata.media.generator.default
thumbnail: sonata.media.thumbnail.format
allowed_extensions: ['jpg', 'png', 'jpeg']
allowed_mime_types: ['image/pjpeg', 'image/jpeg', 'image/png', 'image/x-png']
youtube:
service: sonata.media.provider.youtube
resizer: sonata.media.resizer.simple
filesystem: sonata.media.filesystem.s3
cdn: sonata.media.cdn.server
generator: sonata.media.generator.default
thumbnail: sonata.media.thumbnail.format
html5: false
dailymotion:
service: sonata.media.provider.dailymotion
resizer: sonata.media.resizer.simple
filesystem: sonata.media.filesystem.s3
cdn: sonata.media.cdn.server
generator: sonata.media.generator.default
thumbnail: sonata.media.thumbnail.format
contexts:
default: # the default context is mandatory
download:
strategy: sonata.media.security.forbidden_strategy
mode: http
providers:
- sonata.media.provider.dailymotion
- sonata.media.provider.youtube
- sonata.media.provider.image
- sonata.media.provider.file
formats:
small: { width: 100 , quality: 70}
big: { width: 500 , quality: 70}
cdn:
server:
path: %s3_bucket_path%/uploads/media/
#cloufront: ~
# path: http://%cloudfront_domain%.cloudfront.net/uploads/media
# distribution_id: %cloudfront_id%
# key: %cloudfront_key%
# secret: %cloudfront_secret%
filesystem:
local:
directory: %kernel.root_dir%/../web/uploads/media
create: false
s3:
bucket: %bucket_name"
accessKey: %access_key%
secretKey:%secret_key%
region: