The case: I’ve tried to integrate spaces to save images of my app. I created spaces and followed the steps of adding info of space into filesystem
'do_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_ENDOINT'),
],`
'default' => env('FILESYSTEM_DRIVER', 'local'),
'cloud' => env('FILESYSTEM_CLOUD', 'do_spaces'),
then I tried to save images to the space using next line and different other lines
$imagePath = $imageFile->store('/', 'do_spaces');
but It always generate an exception
The Issue(Exception):-
Aws\S3\Exception\S3Exception: Error executing "PutObject" on "https://spaceName.s3.fra1.amazonaws.com/gYuhUz5i1XYOKHPBLZ128fJQWhJ9wb4ml4JuhTev.png"; AWS HTTP error: cURL error 6: Could not resolve host: spaceName.s3.fra1.amazonaws.com (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://spaceName.s3.fra1.amazonaws.com/gYuhUz5i1XYOKHPBLZ128fJQWhJ9wb4ml4JuhTev.png in file projectPath/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php on line 195
#0 projectPatch/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php(97): Aws\WrappedHttpHandler->parseError(Array, Object(GuzzleHttp\Psr7\Request), Object(Aws\Command), Array)
#1 /projectPath/vendor/guzzlehttp/promises/src/Promise.php(204): Aws\WrappedHttpHandler->Aws\{closure}(Array)
#2 projectPath/vendor/guzzlehttp/promises/src/Promise.php(169): GuzzleHttp\Promise\Promise::callHandler(2, Array, NULL)
#3 projectPath/vendor/guzzlehttp/promises/src/RejectedPromise.php(42): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}(Array)........
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.
Hi there,
Indeed, you should not use
spaceName.s3.fra1.amazonaws.com
as the hostname as I believe that it is not a valid endpoint. The endpoint should look something like thishttps://ams3.digitaloceanspaces.com
.For PHP it would look as follows:
If you are using Laravel, you could follow the instructions here from step 5:
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-scalable-laravel-6-application-using-managed-databases-and-object-storage#step-5-integrating-an-s3-compatible-object-storage-into-the-application
Best,
Bobby