3

Is there any RiakCS S3 PHP client library out there? The best I could find was S3cmd command line client software.

Also I've seen there is Riak PHP Client, but it looks like there is nothing related to S3.

I've installed aws-sdk-php-laravel and used same credentials as for RiakCS S3 but it doesn't seem to work. Error message below:

The AWS Access Key Id you provided does not exist in our records.

Thank you for any guidance or advice.

mintaras
  • 301
  • 3
  • 11

2 Answers2

4

Actually, if you are using Riak, it wouldn't be a proxy, it would be a completely different endpoint. So you should do it this way with the base_url option:

$s3 = S3Client::factory([
    'base_url'       => 'http://127.0.0.1:8080',
    'region'         => 'my-region',
    'key'            => 'my-key',
    'secret'         => 'my-secret',
    'command.params' => ['PathStyle' => true]
]);

Using 'command.params' allows you to set a parameter used in every operation. You will need to use the 'PathStyle' option on every request to make sure the SDK does not move your bucket into the host part of the URL like it is supposed to do for Amazon S3.

This is was all talked about on an issue on GitHub.

Jeremy Lindblom
  • 6,437
  • 27
  • 30
2

aws-sdk-php-laravel uses aws-sdk-php which is hard coded to use Amazon's URLs. If you want to use that library with Riak CS, you'll need to configure it to use your node as a proxy. According to the config docs that would be set using:

use Aws\S3\S3Client;

$s3 = S3Client::factory(array(
    'request.options' => array(
        'proxy' => '127.0.0.1:8080'
    )
));

I haven't used Laravel, so I'm not sure where to put that so that it will pass the setting along to

Joe
  • 25,000
  • 3
  • 22
  • 44
  • This looks promising, but when I use this I'm getting other error: `Error retrieving credentials from the instance profile metadata server. When you are not running inside of Amazon EC2, you must provide your AWS access key ID and secret access key in the "key" and "secret" options when creating a client or provide an instantiated Aws\Common\Credentials\CredentialsInterface object. ([curl] 28: Connection timed out after 5013 milliseconds` – mintaras Jul 21 '14 at 15:10
  • after this I tried to set my credentials manually again (though it sits in config file tight). `$credentials = $s3->getCredentials(); $credentials->setAccessKeyId('key'); $credentials->setSecretKey('secret'); $credentials->setExpiration(null);` But after this I got other error: `[curl] 56: Proxy CONNECT aborted [url] https://my-test-bucket.s3.amazonaws.com/testFile.txt` – mintaras Jul 21 '14 at 15:39