Question

Spaces - How to force the check of content-md5 when using PostObjectV4 in PHP?

I have a code that works well with S3, but after switching to Spaces it doesn’t check the MD5 hash. So even if I change the $md5 variable, the upload finishes successfully.

The fun fact is that this is only a problem with content-md5. The content-type check works fine.

Is there a way to check the file integrity after uploading in Spaces?

I have no idea how to fix it.

$formInputs = [
    'acl'                   => 'private',
    'key'                   => $name,
    'success_action_status' => '201',
    'content-md5'           => $md5,
    'content-type'          => $contentType,
];

$options = [
    ['acl' => 'private'],
    ['bucket' => $bucket],
    ['success_action_status' => '201'],
    ['content-md5' => $md5],
    ['content-type' => $contentType],
    ['content-length-range', 0, 1024 * 1024 * 100],
    ['starts-with', '$key', $userId . '/'],
];

$postObject = new PostObjectV4($client, $bucket, $formInputs, $options, '+15 minutes');

$formAttributes = $postObject->getFormAttributes();
$formInputs     = $postObject->getFormInputs();

return [$formAttributes, $formInputs];

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

Try DigitalOcean for free

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

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

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

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
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
Get started for free

Enter your email to get $200 in credit for your first 60 days with DigitalOcean.

New accounts only. By submitting your email you agree to our Privacy Policy.

© 2023 DigitalOcean, LLC.