DigitalOceanPHP / Client

DigitalOcean API v2 client for PHP
MIT License
709 stars 205 forks source link

any support for the new spaces api? #189

Closed bitgandtter closed 4 years ago

bitgandtter commented 7 years ago

Im really interested on using the new spaces api, there is any support already or in the upcoming months?

vekien commented 6 years ago

This would be greatly appreciated, tempted to look at it myself. For those who are coming here looking for support and need a solution now, due to the simplistic object implementation digital ocean has you can just use Amazon PHP SDK and connect to it via their S3 client.

https://www.digitalocean.com/community/questions/how-to-uses-digitalocean-spaces-with-the-aws-s3-sdks

<?php

// Included aws/aws-sdk-php via Composer's autoloader
// Installed with: composer.phar require aws/aws-sdk-php
require 'vendor/autoload.php';
use Aws\S3\S3Client;

// Configure a client using Spaces
$client = new Aws\S3\S3Client([
        'version' => 'latest',
        'region'  => 'nyc3',
        'endpoint' => 'https://nyc3.digitaloceanspaces.com',
        'credentials' => [
                'key'    => 'ACCESS_KEY',
                'secret' => 'SECRET_KEY',
            ],
]);

// Create a new Space
$client->createBucket([
    'Bucket' => 'my-new-space-with-a-unique-name',
]);

// Listing all Spaces in the region
$spaces = $client->listBuckets();
foreach ($spaces['Buckets'] as $space){
    echo $space['Name']."\n";
}

// Upload a file to the Space
$insert = $client->putObject([
     'Bucket' => 'my-new-space-with-a-unique-name',
     'Key'    => 'file.ext',
     'Body'   => 'The contents of the file'
]);
GrahamCampbell commented 4 years ago

We don't be supporting the spaces API here (apart from possibly a small number of meta methods) because their API was designed to be S3-compatible, so you can just use Amazon's SDK (https://github.com/aws/aws-sdk-php) or alternative S3 clients such as https://github.com/async-aws/aws.