Zak
Zak

Reputation: 81

Can I change the provider to use aws / aws-sdk-php?

I am searching a library PHP to use the S3 protocol only (not AWS S3 by Amazon).

And I found the AWS SDK for PHP : https://github.com/aws/aws-sdk-php .

But, can I change the provider to use it ?

For example : Can I manage S3 servers of Scaleway ? Ceph ? And so on ?

Thank you :)

Zak,

Upvotes: 0

Views: 482

Answers (1)

Ovidiu
Ovidiu

Reputation: 157

Not sure if still relevant for you, but I did manage to use the AWS SDK for PHP with Scaleway Object Storage.

The only trick is to set bucket-endpoint to true, provide the endpoint as the bucket endpoint from your bucket settings in Scaleway, and one more crucial thing, provide the credentials as array, instead of letting the SDK generate / check them. See code sample below:

$client = new Aws\S3\S3Client([
    'version' => 'latest',
    'region' => 'bucketregion', //eg. 'fr-par'
    'credentials' => [
        'key'    => 'your access key',
        'secret' => 'your secret key',
    ],
    'endpoint' => 'http://mybucket.s3.fr-par.scw.cloud',
    'bucket_endpoint' => true
]);

try {
    $client->putObject(array(
        'Bucket'=>'butcketname',
        'Key' =>  'path-where-you-want-to-upload-in-bucket',
        'SourceFile' => 'system-path-to-file',
        'ACL'    => 'public-read', //for public access
    ));
} catch (S3Exception $e) {
    //code when fails
}

I just used this code as I had the same issue and I can 100% confirm this code works to upload files to Scaleway object storage by using AWS PHP SDK, as of April 2022.

Hope it helps.

Upvotes: 1

Related Questions