Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jimmyphong's avatar

Laravel 8 and Digitalocean spaces using S3

Anyone did success for upload to Digitalocean spaces for laravel 8

here is my composer

"laravel/framework": "^8.54",
"league/flysystem-aws-s3-v3": "^1.0",

in filesystems.php

'spaces' => [
   'driver' => 's3',
   'key' => env('SPACES_ACCESS_KEY_ID', '===AAACESS KEY==='),
   'secret' => env('SPACES_SECRET_ACCESS_KEY', '===BBBSECRECT KEY==='),
   'region' => env('SPACES_DEFAULT_REGION', 'sgp1'),
   'bucket' => env('SPACES_BUCKET', 'laravel-spaces'),
   'url' => env('SPACES_URL', 'https://laravel-spaces.sgp1.cdn.digitaloceanspaces.com'),
   'endpoint' => env('SPACES_ENDPOINT', 'https://sgp1.digitaloceanspaces.com')
],

Tinker upload test

$path = 'thumb.png';
$file = Storage::disk('spaces')->put($path, @file_get_contents(public_path('images/logo.png')));

Errors

Aws\S3\Exception\S3Exception with message 'Error executing "PutObject" on "https://laravel-spaces.s3.sgp1.amazonaws.com/thumb.png"; AWS HTTP error: cURL error 6: Could not resolve: laravel-spaces.s3.sgp1.amazonaws.com (Domain name not found) (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://laravel-spaces.s3.sgp1.amazonaws.com/thumb.png'
*** Execution finished ***
                              

Why append s3 and amazonaws.com to url

And how to solve this

Thanks.

0 likes
4 replies
Snapey's avatar

what's in .env ?

have you run artisan config:clear

jimmyphong's avatar

@Snapey i set in second parameter with exclude .env file. Also clear config but still not work.

Snapey's avatar

@jimmyphong It only uses the second parameter if the first does not exist. So if you still have S3 credentials in the .env file then they will be used. You should move these values to .env to avoid you committing the credentials with your source code.

Please or to participate in this conversation.