tinify/tinify-php

S3 bucket name cannot include dot (.)

george-oakling opened this issue · 4 comments

Hi! Amazing job you've done! I am using this library almost daily :) Now I tried to implement the S3 upload, which is integrated into the PHP API you provide. It works quite well, with one exception - if the bucket includes dot, the upload to S3 fails with 500 HTTP error code. Example:

$source->store([
            'service' => 's3',
            'aws_access_key_id' => $this->awsId,
            'aws_secret_access_key' => $this->awsKey,
            'path' => 'example/file.png'
        ]); // OK

$source->store([
            'service' => 's3',
            'aws_access_key_id' => $this->awsId,
            'aws_secret_access_key' => $this->awsKey,
            'path' => 'example.com/file.png' // bucket name example.com does not work!
        ]); // 500 ERROR

This is actually a problem with the API itself rather than the client. There are some restrictions on how S3 buckets can be accessed, which depend on whether or not buckets include a .. Probably we will start requiring you to provide the AWS region as well. We are working on a solution, and we'll post an update here once it's finished. Thanks for reporting it!

Okay, thanks a lot. I was just surprised, because my apps in PHP are working with buckets like example.com with no problem (using the official AWS PHP SDK), and then the 500 happened. Sending also the region would not be problem, it is required by official S3Client by AWS. Have a nice day :-)

We have changed our API to support bucket names containing dots (.). In order for this to work, the region has to be specified:

$source->store([
            'service' => 's3',
            'region' => 'eu-west-1',
            'aws_access_key_id' => $this->awsId,
            'aws_secret_access_key' => $this->awsKey,
            'path' => 'example.com/file.png' // bucket name example.com does not work!
        ])

In addition, the new Frankfurt S3 region is supported as well. There is no need to update the PHP client itself.

Thanks again for reporting this!