By hilmanrdn
Hi!
really excited to try digital ocean spaces! I’m currently using Laravel and aws s3 for streaming and download video on my site i’m using aws-sdk-php-laravel right now for generating presigned url for my videos (not the phpleague flysystem)
my question is, how can do this with digitalocean spaces, or rather how can i easily move to do spaces using the same sdk?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Spaces was designed to be inter-operable with the S3 API (for more details see here). This includes the ability to presign URLs. The only difference when porting from a code base originally targeting S3 will be configuring the correct endpoint (e.g. $REGION.digitaloceanspaces.com).
Here’s a quick example with vanilla PHP:
<?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' => 'MY_SPACES_KEY',
'secret' => 'MY_SPACES_SECRET,
],
]);
$cmd = $client->getCommand('GetObject', [
'Bucket' => 'examplebucket',
'Key' => 'file.ext'
]);
$request = $client->createPresignedRequest($cmd, '+5 minutes');
$presignedUrl = (string) $request->getUri();
echo $presignedUrl;
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.