Report this

What is the reason for this report?

How to show DigitalOcean private Spaces CDN temporaryURL on Laravel?

Posted on March 11, 2021

I’ve successfully generated a CDN link in laravel but I stored it in private space. I’m trying to generate a Storage::temporaryUrl for CDN but I’m not sure why it is not showing as CDN link but rather a normal link with temporary key. The CDN link is working with just Storage::URL but when trying to access it I’m getting an Access Denied because it doesn’t have a temporary key.

I was wondering if there is a way to generate a TemporaryURL for CDN link with temporary key



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!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

I believe that Laravel’s file ysystem integration doesn’t natively offer a method to generate temporary URL for private files stored in spaces.

You’re likely seeing a non-CDN link because the URL generation process doesn’t consider the CDN. In Laravel, Storage::temporaryUrl() is only for S3 driver and is only usable if the object is private.

One workaround might be to manually generate the signed URL using the AWS SDK, including the path to the file relative to your Spaces root directory, and set the custom domain to point to your CDN endpoint.

Please note that for the best security practice, remember to not expose any sensitive data or API keys/secrets publicly.

Hope that this helps!

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.