These are chat archives for aws/aws-sdk-php

14th
Oct 2014
Jeremy Lindblom
@jeremeamia
Oct 14 2014 20:43
We just launched the developer preview of Version 3 of the AWS SDK for PHP. See the blog.
Kara Todd
@kara-todd
Oct 14 2014 23:12
Is anyone around to maybe discuss #347 a bit?
Jeremy Lindblom
@jeremeamia
Oct 14 2014 23:20
I may have a few minutes.
Kara Todd
@kara-todd
Oct 14 2014 23:20
That would be great if you do
So I’m not sure if I’m running into a b ug here… or if I’m just not using it right. :)
basically, it seems like the base_url client config option is ignored when using getObjectUrl
Jeremy Lindblom
@jeremeamia
Oct 14 2014 23:22
What code are you using and what are you expecting as output?
Kara Todd
@kara-todd
Oct 14 2014 23:23
$client = S3Client::factory(
    'key' => $key,
    'secret' => $secret,
    'base_url' => 'http://s3.example.com/bucket',
);
$url = $client->getObjectUrl('bucket', 'test.txt');
and I would like to get back http://s3.example.com/bucket/test.txt
but I keep getting: http://bucket.s3.example.com/test.txt
Jeremy Lindblom
@jeremeamia
Oct 14 2014 23:26
Are you getting: http://bucket.s3.example.com/test.txt or http://bucket.s3.amazonaws.com/test.txt?
Kara Todd
@kara-todd
Oct 14 2014 23:26
oops sorry. yes http://bucket.s3.amazonaws.com/test.txt
Jeremy Lindblom
@jeremeamia
Oct 14 2014 23:29
Yeah, I don't believe the S3Client works with cnames right out of the box. I explained it to someone else how to do it a few weeks ago. Let me look for that convo.
Kara Todd
@kara-todd
Oct 14 2014 23:29
thanks
Jeremy Lindblom
@jeremeamia
Oct 14 2014 23:34
Are you doing pre-signed URLs, or are these just plain URLs?
Kara Todd
@kara-todd
Oct 14 2014 23:36
uhm. Not sure… I’m working with another library that is using the SDK. From what I can tell, it just passes those config settings directly into the factory, and then calls getObjectUrl on the created S3 client using the bucket and path.
Jeremy Lindblom
@jeremeamia
Oct 14 2014 23:37
Easy way to check: does it have ?query=string&parameters=after&the=url
Kara Todd
@kara-todd
Oct 14 2014 23:37
it does not
Jeremy Lindblom
@jeremeamia
Oct 14 2014 23:40
Then it is not pre-signing, it's just generating a URL. This does not require the SDK, it's just a concatenation: "http://{$cname}/{$key}", right?
what lib are you using?
I wasn’t sure if I should ask for the url call to be modified in that library, or if the s3 SDK should take care of it...
Jeremy Lindblom
@jeremeamia
Oct 14 2014 23:44
So the issue is that you a using a cname to a bucket, not an actual bucket name. The SDK doesn't know that, so it is doing the same thing it does with other bucket names (e.g., treats the bucket name like a subdomain to s3.amazonaws.com)
Kara Todd
@kara-todd
Oct 14 2014 23:46
So should the call be made a different way? That’s what I wasn’t sure about… I can patch in a fix to re-write the url in this fucntion, but I didn’t know if that would be getting in the way of the SDK, or if there was a more suitable call to make than getObjectUrl
Jeremy Lindblom
@jeremeamia
Oct 14 2014 23:49
$url = $s3Client->getObjectURL('bucket', 'test.txt', null, ['PathStyle' => true]); doing this prevents the SDK from moving the bucket to the subdomain.
$s3Client = Aws\S3\S3Client::factory([
    'base_url' => 'http://s3.example.com',
]);

$url = $s3Client->getObjectURL('bucket', 'test.txt', null, ['PathStyle' => true]);
//> http://s3.example.com/bucket/test.txt
Kara Todd
@kara-todd
Oct 14 2014 23:51
ah! amazing. Great! Thank you so much. :)
Jeremy Lindblom
@jeremeamia
Oct 14 2014 23:52
np