System error occurred
The path of a URI with an authority must start with a slash "/" or be empty.
Automagically fixing the URI by adding a leading slash to the path is
deprecated since version 1.4 and will throw an exception instead.
line#755 file: /home/mySite/www/vendor/guzzlehttp/psr7/src/Uri.php
PHP version: 7.4.14
Error executing "PutObject" on "//mySite.nyc3.digitaloceanspaces.com/mySite.nyc3.digitaloceanspaces.com";
AWS HTTP error:
Server error:
PUT http://mySite.nyc3.digitaloceanspaces.com/mySite.nyc3.digitaloceanspaces.com
resulted in a `501 Not Implemented` response:
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>NotImplemented</Code>
<RequestId>tx00000000000000c12754f-0060564e57-96 (truncated...)
NotImplemented (server):
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>NotImplemented</Code>
<RequestId>tx00000000000000c12754f-0060564e57-9617be5-nyc3c</RequestId
<HostId>9617be5-nyc3c-nyc3-zg03</HostId>
</Error>"
I don't fully understand this error, I have tried changing the header request, I don't know what else to try, I am blank at the moment. I have also assumed it is a problem in the headers. Currently my header request looks like this:
:authority: mySite.com
:method: POST
:path: /request.ajax.php
:scheme: https
I will also leave the respective php codes:
function __construct($key, $secret_key, $space)
{
$this->space = $space;
try {
$this->client = new \Aws\S3\S3Client([
'version' => 'latest',
'region' => 'us-east-1',
'endpoint' => 'nyc3.digitaloceanspaces.com',
'credentials' => [
'key' => $key,
'secret' => $secret_key
],
]);
} catch (\Exception $e) {
return $e->getMessage();
}
}
public _upload($path, $resource, $ctype)
{
try {
$this->client->putObject(array(
'Bucket' => $this->space,
'Key' => $path,
'Body' => $resource,
'ACL' => 'public-read',
'ContentType' => $ctype
));
} catch (\Exception $e) {
return $e->getMessage();
}
return array("status" => "Success.");
}
part where I manage the file for the upload:
$path = "test/".basename($_FILES['file']['name']);
$ctype = mime_content_type($_FILES['file']['tmp_name']);
$stream = fopen($_FILES['file']['tmp_name'], 'r+');
$out = $xspaces->_upload($path, $stream, $ctype);
fclose($stream);
After follow this article, I Have same issue just change your .env and add protocol to endpoint
without protocol i got same error (wrong)
DO_SPACES_ENDPOINT=sgp1.digitaloceanspaces.com
fix just add protocal to do_space (correct)
DO_SPACES_ENDPOINT=https://sgp1.digitaloceanspaces.com