Created
September 24, 2014 15:06
-
-
Save viccherubini/e3107493f078516555f3 to your computer and use it in GitHub Desktop.
AWS SDK base_url Questions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Configuration, using AWS SDK 2.6.16 | |
return [ | |
'includes' => ['_aws'], | |
'services' => [ | |
'default_settings' => [ | |
'params' => [ | |
'key' => 'xxx', | |
'secret' => 'yyyy', | |
'base_url' => 'http://files.example.com' | |
] | |
] | |
] | |
]; | |
// Assume $s3Client is constructed with config above. | |
$result = $s3Client->putObject([ | |
'Bucket' => 'files.example.com', | |
'Key' => 'image.jpg', | |
'SourceFile' => '/path/to/image.jpg', | |
'ContentType' => 'image/jpeg', | |
'ACL' => CannedAc::PUBLIC_READ | |
]); | |
// Receive this error: | |
// [curl] 6: Couldn't resolve host 'files.example.com.files.example.com' [url] http://files.example.com.files.example.com/image.jpg | |
// It seems it attempts to create the URL as: scheme://<bucket-name>.<base-url>. | |
// If you have a CNAME that points files.example.com to files.example.com.s3.amazonaws.com this won't work. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@jeremeamia 1 year later and I'm finding this info useful. I setup cname with aws sdk php using this information here:
aws/aws-sdk-php#347
The getObjectUrl works fine yet the upload part gives me the exact same issue as described above. I will try your solution now. I wonder if this is caused by me using SDK 2?