Using Spaces, I get a (403) Forbidden error when trying to load an image on my website.

Posted April 7, 2019 5.6k views

I have a few files uploaded to my spaces droplet (if that is the correct terminology). When I attempt to access a .jpg image from my website, the console throws a (403) Forbidden error when trying to access it.

Thanks to everyone in advance.

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.

Submit an Answer
2 answers

Spaces is DO’s Object Storage solution as opposed to Droplet’s which is a compute platform :-)

Usually files uploaded to Spaces are private by default. You can chance the setting at a file level for every file you upload. Can you please make sure your files are not uploaded with the default “private” setting? If it is, please switch this to public. You can do this from our cloud portal or via our API.

In my case, I integrated the S3 API with a Laravel application. And then used Laravel Media Library to upload (PUT) and view (GET) images on the site… Even though uploading was okay, I was getting 403 forbidden requests for viewing those files!

And thanks to the support, they pointed out that you can view the individual file’s permission within the Space storage in DigitalOcean, and then it hit me! The files were uploaded without the necessary x-amz-acl header that is set to public-read and it was defaulted to private!-_-’

Anyhow, thanks to the amazing Laravel Media Library package, its configuration included an array for extra headers to be attached to the PUT HTTP requests.