Developer
Been seeing a few questions surrounding this issue and it seems like the tutorials for this aren’t very clear.
I followed the guide here
So I have a few questions since this is not working:
$cmd = $client->getCommand('GetObject', [
'Bucket' => 'example-space-name',
'Key' => 'path/to/file.ext'
]);
$request = $client->createPresignedRequest($cmd, '+5 minutes');
$presignedUrl = (string) $request->getUri();
echo $presignedUrl."\n";
// https://mycdn.website.com/example-space-name/path/to/file.ext
That path is incorrect I believe. It should be:
https://mycdn.website.com/path/to/file.ext
When I was testing with the endpoint values, I was getting a mix of XML error responses. Either AccessDenied or SignatureMismatch.
One last thing, I noticed this text in regards to using a CDN:
You can use presigned URLs with the Spaces CDN. To do so, configure your SDK or S3 tool to use the non-CDN endpoint, generate a presigned URL for a GetObject request, then modify the hostname in the URL to be the CDN hostname (<space-name>.<region>.cdn.digitaloceanspaces.com, unless the Space uses a custom hostname).
I don’t see a code example for this case in PHP or any of the other languages.
Where am I going wrong here?
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!
I’m struggling with the same issue here. Does anyone from DO have any advice?
I have the same issue. I can’t just substitute the URL like they say in the documentation.
I got SignatureMismatch
I’ll just chime in here that our team got this working using this pre-signer AWS S3 package
And code like:
const bucketParams: PutObjectCommandInput = {
Bucket: this.digitalOceanSpace,
Key: generateFilePath(metadata),
};
return await getSignedUrl(this.client, new GetObjectCommand(bucketParams), {
expiresIn: 15 * 60,
});
To generate the pre-signed download URL with a URL like https://SPACE-NAME.REGION.digitaloceanspaces.com/…
Then were able to swap the URL domain (just using a RegEx) to https://SUBDOMAIN.DOMAIN.com/…
And it worked just fine. Our custom CDN domain was set up using an external DNS provider, and the certs created using certbot and added manually via the DO UI.
Hope this helps anyone else!
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.