Matt Davis
Matt Davis

Reputation: 1337

DigitalOcean Spaces / Amazon S3 "InvalidArgument: null at Request.extractError"

InvalidArgument: null
    at Request.extractError (P:\Upwork\MyProject\backend\node_modules\aws-sdk\lib\services\s3.js:700:35)
    at Request.callListeners (P:\Upwork\MyProject\backend\node_modules\aws-sdk\lib\sequential_executor.js:106:20)
    at Request.emit (P:\Upwork\MyProject\backend\node_modules\aws-sdk\lib\sequential_executor.js:78:10)
    at Request.emit (P:\Upwork\MyProject\backend\node_modules\aws-sdk\lib\request.js:688:14)
    at Request.transition (P:\Upwork\MyProject\backend\node_modules\aws-sdk\lib\request.js:22:10)
    at AcceptorStateMachine.runTo (P:\Upwork\MyProject\backend\node_modules\aws-sdk\lib\state_machine.js:14:12)
    at P:\Upwork\MyProject\backend\node_modules\aws-sdk\lib\state_machine.js:26:10
    at Request.<anonymous> (P:\Upwork\MyProject\backend\node_modules\aws-sdk\lib\request.js:38:9)
    at Request.<anonymous> (P:\Upwork\MyProject\backend\node_modules\aws-sdk\lib\request.js:690:12)
    at Request.callListeners (P:\Upwork\MyProject\backend\node_modules\aws-sdk\lib\sequential_executor.js:116:18) {
  code: 'InvalidArgument',
  region: null,
  time: 2020-12-31T15:39:45.724Z,
  requestId: '',
  extendedRequestId: undefined,
  cfId: undefined,
  statusCode: 400,
  retryable: false,
  retryDelay: 85.1667642693943
}

This error occurs when trying to upload to DigitalOcean Spaces or Amazon S3.

The error message is very vague just supplying InvalidArgument as a reason.

Upvotes: 1

Views: 2253

Answers (1)

Matt Davis
Matt Davis

Reputation: 1337

code: 'InvalidArgument' suggests that there is an issue with the supplied uploadParams.

const uploadParams = {
    Bucket: process.env.DIGITAL_OCEAN_PUBLIC_SPACE_NAME,
    Key: `profile-picture/${userUUID}.jpg`,
    Body: body,
    ACL: 'public',
};

In my case we can see above that I was trying to use ACL: 'public'.

This is not a valid ACL value, a value of ACL: 'public-read' should be used. For private objects you should use ACL: 'private'. The documentation can be found here.

If you receive this error check that your bucket name, ACL values and all of your uploadParams are valid.

Upvotes: 10

Related Questions