将 aws-s3-v3 与 laravel 和 digitalocean 空间一起使用会导致错误 501 未实现
Using aws-s3-v3 with laravel and digitalocean spaces results in error 501 not implemented
我正在尝试使用 Laravel 8
和 flysystem-aws-s3-v3
.
从 digitalocean(空间)上传一些文件到 s3
兼容存储
但是当我提交这些文件时出现了这个错误:
Aws\S3\Exception\S3Exception
Error executing "PutObject" on "//SPACES_NAME.nyc3.digitaloceanspaces.com/SPACES_NAME.nyc3.digitaloceanspaces.com"; AWS HTTP error: Server error: `PUT http://SPACES_NAME.nyc3.digitaloceanspaces.com/SPACES_NAME.nyc3.digitaloceanspaces.com` resulted in a `501 Not Implemented` response: <?xml version="1.0" encoding="UTF-8"?><Error><Code>NotImplemented</Code><RequestId>tx00000000000000bf40fd9-00605636a9-96 (truncated...) NotImplemented (server): - <?xml version="1.0" encoding="UTF-8"?><Error><Code>NotImplemented</Code><RequestId>tx00000000000000bf40fd9-0060
5636a9-9617be5-nyc3c9617be5-nyc3c-nyc3-zg03
这是我来自 .env
的 digitalocean 常量:
DO_SPACES_ACCESS_KEY=[edit]
DO_SPACES_SECRET_ACCESS_KEY=[edit]
DO_SPACES_ENDPOINT=nyc3.digitaloceanspaces.com
DO_SPACES_REGION=nyc3
DO_SPACES_BUCKET=SPACES_NAME
DO_URL=https://SPACES_NAME.nyc3.cdn.digitaloceanspaces.com
这是来自 config/filesystem.php
的配置部分:
'disks' => [
...
'do' => [
'driver' => 's3',
'key' => env('DO_SPACES_ACCESS_KEY'),
'secret' => env('DO_SPACES_SECRET_ACCESS_KEY'),
'region' => env('DO_SPACES_REGION'),
'bucket' => env('DO_SPACES_BUCKET'),
'endpoint' => env('DO_SPACES_ENDPOINT'),
'url' => env('DO_URL'),
],
],
这是我用来处理上传的测试方法:
Route::post('upload', function(){
$extension = request()->file('file')->extension();
$path = Storage::disk('do')->putFileAs('upload', request()->file('file'), time() . '.' .$extension, 'public');
});
关于如何修复此 501 not implemented
错误的任何想法?我看到 url 由于某种原因出现了两次,我认为这与它有关 :-?
我解决了同样的问题如下:
- 将以下端点添加到
.env
文件
DO_SPACES_ENDPOINT=https://SPACES_NAME.nyc3.digitaloceanspaces.com
- 将
config/filesystem.php
文件中的选项添加到您的 DO Space。
'bucket_endpoint' => true
- 清除缓存。
我正在尝试使用 Laravel 8
和 flysystem-aws-s3-v3
.
s3
兼容存储
但是当我提交这些文件时出现了这个错误:
Aws\S3\Exception\S3Exception
Error executing "PutObject" on "//SPACES_NAME.nyc3.digitaloceanspaces.com/SPACES_NAME.nyc3.digitaloceanspaces.com"; AWS HTTP error: Server error: `PUT http://SPACES_NAME.nyc3.digitaloceanspaces.com/SPACES_NAME.nyc3.digitaloceanspaces.com` resulted in a `501 Not Implemented` response: <?xml version="1.0" encoding="UTF-8"?><Error><Code>NotImplemented</Code><RequestId>tx00000000000000bf40fd9-00605636a9-96 (truncated...) NotImplemented (server): - <?xml version="1.0" encoding="UTF-8"?><Error><Code>NotImplemented</Code><RequestId>tx00000000000000bf40fd9-0060
5636a9-9617be5-nyc3c9617be5-nyc3c-nyc3-zg03
这是我来自 .env
的 digitalocean 常量:
DO_SPACES_ACCESS_KEY=[edit]
DO_SPACES_SECRET_ACCESS_KEY=[edit]
DO_SPACES_ENDPOINT=nyc3.digitaloceanspaces.com
DO_SPACES_REGION=nyc3
DO_SPACES_BUCKET=SPACES_NAME
DO_URL=https://SPACES_NAME.nyc3.cdn.digitaloceanspaces.com
这是来自 config/filesystem.php
的配置部分:
'disks' => [
...
'do' => [
'driver' => 's3',
'key' => env('DO_SPACES_ACCESS_KEY'),
'secret' => env('DO_SPACES_SECRET_ACCESS_KEY'),
'region' => env('DO_SPACES_REGION'),
'bucket' => env('DO_SPACES_BUCKET'),
'endpoint' => env('DO_SPACES_ENDPOINT'),
'url' => env('DO_URL'),
],
],
这是我用来处理上传的测试方法:
Route::post('upload', function(){
$extension = request()->file('file')->extension();
$path = Storage::disk('do')->putFileAs('upload', request()->file('file'), time() . '.' .$extension, 'public');
});
关于如何修复此 501 not implemented
错误的任何想法?我看到 url 由于某种原因出现了两次,我认为这与它有关 :-?
我解决了同样的问题如下:
- 将以下端点添加到
.env
文件
DO_SPACES_ENDPOINT=https://SPACES_NAME.nyc3.digitaloceanspaces.com
- 将
config/filesystem.php
文件中的选项添加到您的 DO Space。
'bucket_endpoint' => true
- 清除缓存。