File Upload Read Permissions on DO Spaces

Posted September 17, 2017 7.9k views
PHP FrameworksUbuntu 16.04Storage

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;

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.


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

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.

  • Just tried it, I get a 403.

    PUT /2017-10-17/acl.conf4 HTTP/1.1
    User-Agent: curl/7.29.0
    Accept: /
    x-amz-acl: public-read
    Date: Tue, 17 Oct 2017 09:48:59 +0000
    Content-Type: text/plain
    Authorization: AWS …
    Content-Length: 2816
    Expect: 100-continue

    Got 403