I am trying to upload some files to a s3
compatible storage from digitalocean (spaces) using Laravel 8
and flysystem-aws-s3-v3
.
But when I submit those files I'm getting this error:
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
Here are my digitalocean constants from .env
:
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
And here is the config part from 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'),
],
],
And this is the test method that I'm using to process uploads:
Route::post('upload', function(){
$extension = request()->file('file')->extension();
$path = Storage::disk('do')->putFileAs('upload', request()->file('file'), time() . '.' .$extension, 'public');
});
Any thoughts on how this 501 not implemented
error could be fixed? I see that the url for some reason appears twice and I think that that has something to do with it :-?
I solved the same problem as follows:
.env
file DO_SPACES_ENDPOINT=https://SPACES_NAME.nyc3.digitaloceanspaces.com
config/filesystem.php
file to your DO Space. 'bucket_endpoint' => true