Search code examples
symfonyamazon-web-servicesamazon-s3symfony-2.4gaufrette

Error when attempting upload to S3 with gaufrette


I'm trying to use the KNPLabs gaufrette bundle to upload image files to S3. I'm getting the following error when I debug the response from S3:

The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.

images.mynamespace.com.s3.amazonaws.com

I've tried setting the base_url parameter to that endpoint but still get the same error. There are other questions on SO suggesting setting the region which I have also tried.

The bucket I'm trying to upload to is in the EU West region (Ireland). No matter what config I try, gaufrette still seems to be trying to use s3.amazonaws.com

How can I configure gaufrette correctly?

config.yml:

knp_gaufrette:
    adapters:
        image_storage:
            amazon_s3:
                amazon_s3_id: mynamespace_admin.amazon_s3
                bucket_name:  %amazon_s3_bucket_name%
                create:       false
                options:
                    create:     true
                    directory: 'dirname'
                    region:     eu-west-1


    filesystems:
        image_storage:
            adapter:    image_storage
            alias:      image_storage_filesystem

Solution

  • I needed to set region to s3-eu-west-1.amazonaws.com
    
    knp_gaufrette:
        adapters:
            image_storage:
                amazon_s3:
                    amazon_s3_id: mynamespace_admin.amazon_s3
                    bucket_name:  %amazon_s3_bucket_name%
                    create:       false
                    options:
                        create:     true
                        directory: 'dirname'
                        region:     s3-eu-west-1.amazonaws.com