I’ve been searching and following documentations & videos but can’t seem to make DigitalOcean Spaces work with Laravel 10
DO_SPACES_KEY=key
DO_SPACES_SECRET=secret
DO_SPACES_ENDPOINT=https://sgp1.digitaloceanspaces.com
DO_SPACES_REGION=sgp1
DO_SPACES_BUCKET=db-sys-attachments
DO_SPACES_URL=https://db-sys-attachments.sgp1.digitaloceanspaces.com
'spaces' => [
'driver' => 's3',
'key' => env('DO_SPACES_KEY'),
'secret' => env('DO_SPACES_SECRET'),
'region' => env('DO_SPACES_REGION'),
'bucket' => env('DO_SPACES_BUCKET'),
'endpoint' => env('DO_SPACES_ENDPOINT'),
'url' => env('DO_SPACES_URL'),
'throw' => true,
],
if (!Storage::disk('spaces')->put($folder . '/' . $filename, file_get_contents($attachment), 'public')) {
return false;
}
Response
Unable to write file at location: profiles/1-cor-sample.jpg.
the file comes from the request
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.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Hey!
There are a few things that I could suggest checking, starting by ensuring your
.env
configuration matches your DigitalOcean Spaces details accurately. It’s good to double-check for any typos or incorrect values, especially inDO_SPACES_KEY
,DO_SPACES_SECRET
,DO_SPACES_REGION
, andDO_SPACES_BUCKET
. Your endpoint and URL seem correctly configured for the Singapore region (sgp1
).After that out of the way, I could suggest adding
'visibility' => 'public'
setting to your filesystem as it will be needed to ensure that the images uploaded via the media manager are visible to the public.Then to further diagnose the issue, you can try catching the exception to get more detailed error messages:
This can provide more insight into what’s going wrong, whether it’s a permissions issue, a problem with the file itself, or something else.
Also, what I could suggest is to try writing a simple text file to Spaces to rule out issues with the
$attachment
variable or its contents:If this works, the issue might be with how you’re handling or referencing
$attachment
.Let me know how it goes!
Best,
Bobby