0
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
}

尝试上传到 DigitalOcean Spaces 或 Amazon S3 时会发生此错误。

错误消息非常模糊,只是InvalidArgument作为一个原因提供。

4

1 回答 1

4

code: 'InvalidArgument'表明提供的uploadParams.

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

就我而言,我们可以在上面看到我试图使用ACL: 'public'.

这不是一个有效的 ACL 值,ACL: 'public-read'应该使用 的值。对于私有对象,您应该使用ACL: 'private'. 文档可以在这里找到

如果您收到此错误,请检查您的存储桶名称、ACL 值和所有 uploadParams 是否有效。

于 2020-12-31T15:51:56.943 回答