Laravel 8和Digitalocean空间存储上传



有没有人成功上传到Digitalocean spaces for laravel 8

这是我的作曲家

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

在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上传测试

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

错误
AwsS3ExceptionS3Exception 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 ***

为什么要在url后面加上s3和amazonaws.com

和如何解决这个

谢谢。

感谢所有帮助。我解决了问题,问题是。env文件配置错误。

this is right config

SPACES_ACCESS_KEY_ID=AAAAA
SPACES_SECRET_ACCESS_KEY=BBBB
SPACES_DEFAULT_REGION=sgp1
SPACES_BUCKET=mybucket
SPACES_ENDPOINT=https://mybucket.sgp1.digitaloceanspaces.com
SPACES_URL=https://mybucket.sgp1.cdn.digitaloceanspaces.com

和配置

'spaces' => [
'driver' => 's3',
'key' => env('SPACES_ACCESS_KEY_ID'),
'secret' => env('SPACES_SECRET_ACCESS_KEY'),
'region' => env('SPACES_DEFAULT_REGION'),
'bucket' => env('SPACES_BUCKET'),
'url' => env('SPACES_URL'),
'endpoint' => env('SPACES_ENDPOINT'),
'bucket_endpoint' => true,
'visibility' => 'public',
],

你的错误告诉你到底是什么问题

AwsS3ExceptionS3Exception 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 ***

它不能解析sgp1.amazonaws.com -这意味着你的ENV文件中缺少了一些东西。没有看到env文件,我不能告诉你。

话虽这么说,我明白你试图在filesystems.php中做什么-但是你应该设置ENV中的所有变量,不管你设置回退到

相关内容

  • 没有找到相关文章

最新更新