Question

SignatureDoesNotMatch error with special characters in the file name

When adding a special character to a file name, the file upload results into an error. I’m using the Spaces-API PHP library with the latest AWS S3 client, as recommended in the DigitalOcean documentation.

Example: image.png uploads fine image@2x.png results in error

The error:

Exception has occurred.
GuzzleHttp\Exception\ClientException: Client error: `PUT https://foo.ams3.digitaloceanspaces.com/staging/test/s/Test2%40x5dc343e17c8838.99908039.png` resulted in a `403 Forbidden` response:
<?xml version="1.0" encoding="UTF-8"?><Error><Code>SignatureDoesNotMatch</Code><RequestId>tx00000000000 (truncated...)

Example code to reproduce the error:

// Connect
$space = new SpacesConnect($key, $secret, $space_name, $region);

// Generate file id
$file_id = uniqid('', true);

// File name
$filename  = $file_id . '@2x.png';

// Path to file
$path_file = 'test/' . $filename;

// Upload source file to CDN
$space->UploadFile($data, 'public', $path_file, '', $mime);

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

Solved the issue by patching up the SDK: https://github.com/MelvinRook/Spaces-API

alexdo
Site Moderator
Site Moderator badge
November 7, 2019

Hello, @MelvinRook

I believe this was discussed in https://www.digitalocean.com/community/questions/spaces-php-sdk-changing-acl-error-when-filepath-or-file-contains-symbols-like-an-at

You can check the reply from @efox

Hope this helps!

Regards, Alex

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel