File Upload Read Permissions on DO Spaces

I have been trying out spaces with in my Laravel application’s file uploads feature. While I have successfully uploaded the files from the application using the S3 driver, users cannot view the images uploaded because the images are uploaded with permissions as private in spite of the fact that the bucket itself has public read access. Links to the images return the following error; <Error> <Code>AccessDenied</Code> <BucketName>stevepop</BucketName> <RequestId>99999-nyc3a</RequestId> <HostId>aaaaa-nyc</HostId> </Error>

With Amazon S3, I am able to set the bucket items permission with a policy like the one below; { “Version”: “2008-10-17”, “Statement”: [ { “Sid”: “AllowPublicRead”, “Effect”: “Allow”, “Principal”: { “AWS”: “" }, “Action”: “s3:GetObject”, “Resource”: "arn:aws:s3:::uploads/” } ] }

This way, all file uploads are immediately readable by users.

Is there an equivalent way of doing this in Spaces? If I can’t do this then this feature will not be of any use to me.


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

I find the easiest way to do this is to use Laravel’s putFile method, which allows you to pass the visibility of the uploaded file as an argument. So to store a file with public visibility, you’d do something like the following:

Storage::disk('spaces')->putFile('uploads', request()->file, 'public');

If you use the API, you can add the header x-amz-acl:public-read.