IMB
IMB

Reputation: 15919

Amazon S3: Subdomain mapping with PHP SDK?

How do you make $s3->get_object_url() from PHP SDK return:

http://my-bucket.my-domain.com/example.txt

instead of

http://my-bucket.s3.amazonaws.com/example.txt

Upvotes: 1

Views: 222

Answers (1)

ceejayoz
ceejayoz

Reputation: 180147

S3 doesn't know if a bucketname has a CNAME set up for it, so you'll have to do it yourself. A simple call to preg_replace should work fine.

$url = preg_replace('@^http://my-bucket\.s3\.amazonaws\.com/@Ui', 'http://my-bucket.my-domain.com/', $url);

Upvotes: 2

Related Questions