DO Spaces: ERROR InvalidDigest when s3:nodejs_sdk:putObject with ContentMD5 provided

August 2, 2019 184 views


I wish to use ContentMD5 to insure integrity check for putObject and getObject.

But Spaces always response 400:InvalidDigest when ContentMD5 supplied.

The Spaces client I’m using is

and following is the code for putting object

  params =
    Body: content
    ContentMD5 : crypto.createHash('md5').update(content).digest("hex")
    Bucket: S3_BUCKET_PARAMS,
    ContentType : contentType || "application/json"
    Key: remotePath

  log "[putString] params:", params

  S3Client.putObject params, (err, data) ->
    if err?
      log "[putJsonObject] ERROR:#{err}"
      return callback(err)

    log "[putJsonObject] data:", data
    return callback null, data

and following is the log

 [putString] params: { Body: '{"haha":"nothing"}',
  ContentMD5: 'e829496f87c60b176b2f288020648348',
  Bucket: 'aaa-bbb',
  ContentType: 'application/json',
  Key: '11111/2019/11/09' } +0ms

 err: { InvalidDigest: null
  message: null,
  code: 'InvalidDigest',
  region: null,
  time: 2019-08-02T07:29:39.644Z,
  requestId: 'tx0000000000001e2c28c77-005d43e662-284cc8-sgp1a',
  extendedRequestId: undefined,
  cfId: undefined,
  statusCode: 400,
  retryable: false,
  retryDelay: 96.90178409690691 }

1 Answer

Hey there,

Without full request and response headers, it is difficult for us to say if this is an issue on the client end or the backend with Spaces. Could you write in a ticket to our team:

With those details so we can investigate? Alternatively, you can write those details in here with redacted secrets and we can look to help.

Ethan Fox
Developer Support Engineer II - DigitalOcean

Have another answer? Share your knowledge.

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