0

I am trying to manage DO's Spaces with Laravel's 8 Storage, however I am getting errors which seems to come from Laravel's side.

At start I wrote this line in terminal as I was instructed in Laravel's documentation composer require league/flysystem-aws-s3-v3 "~1.0"

afterwards I edited my environmental variables

DO_SPACES_KEY=*KEY*
DO_SPACES_SECRET=*SECRET*
DO_SPACES_ENDPOINT=ams3.digitaloceanspaces.com
DO_SPACES_REGION=AMS3
DO_SPACES_BUCKET=test-name

also added changes in config/filesystems.php

'do_spaces' => [
            'driver' => 's3',
            'key' => env('DO_SPACES_KEY'),
            'secret' => env('DO_SPACES_SECRET'),
            'endpoint' => env('DO_SPACES_ENDPOINT'),
            'region' => env('DO_SPACES_REGION'),
            'bucket' => env('DO_SPACES_BUCKET'),
        ],

After visiting this test Route

Route::get('/test', function (Request $request) {
    Storage::disk('do_spaces')->put('test.txt', 'hello world');
});

I am getting this error


Error executing "PutObject" on "//test-name./test-name/test.txt"; AWS HTTP error: cURL error 6: Couldn't resolve host 'test-name' (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://test-name./test-name/test.txt


It seems that problem occurs while laravel is trying to compile url which should not look as it is here (wrong - http://test-name./test-name/test.txt). However I have no clue how to fix this issue and what I am doing wrong, since I was following all steps as many tutorials and documetations were telling to do.

4

1 回答 1

0

我有同样的问题。我用下一个方法解决了它:

将 https:// 添加到 DO_SPACES_ENDPOINT ( https://ams3.digitaloceanspaces.com )

在 put 方法中使用 text.txt 的路径:

Storage::disk('do_spaces')->put('YOUR_SPACE_NAME/YOUR_FOLDER_NAME(如果有的话)/test.txt', 'hello world');

于 2021-08-27T08:24:01.463 回答