Node.js 使用S3API删除gcp bucket对象

Node.js 使用S3API删除gcp bucket对象,node.js,google-cloud-platform,aws-sdk,aws-sdk-js,Node.js,Google Cloud Platform,Aws Sdk,Aws Sdk Js,我删除对象的代码如下所示: const s3 = new AWS.S3({ endpoint: spaceEndpoint, accessKeyId, secretAccessKey, }) const params = { Bucket: bucketName, Delete: { Objects: assetsToDelete, }, } try { const res1 = await s3.deleteObjec

我删除对象的代码如下所示:


const s3 = new AWS.S3({
    endpoint: spaceEndpoint,
    accessKeyId,
    secretAccessKey,
})

const params = {
    Bucket: bucketName,
    Delete: {
        Objects: assetsToDelete,
    },
}
try {
    const res1 = await s3.deleteObjects(params).promise()
}catch(e){
    console.log(e)
}

资产ToDelete的价值为

  {
    Key: 'userId/folderName/object1'
  },
  {
    Key: 'userId/folderName/object2'
  }
]
但我有一个错误:

InvalidArgument: Invalid argument.
   ErrorSTACK {
  code: 'InvalidArgument',
  region: null,
  time: 2021-02-12T20:30:42.055Z,
  requestId: null,
  extendedRequestId: undefined,
  cfId: undefined,
  statusCode: 400,
  retryable: false,
  retryDelay: 81.1455003388468
}

上面的配置对于上传和列出对象非常有效。我正在尝试从gcp bucket中删除。

发布时,Google云存储不支持多对象删除

也就是说,您可以删除单个对象。 如果要跟踪此项的添加,可以查看


此外,cloud.google.com/storage/docs/migrating#methods comparison可能有助于比较两个曲面,并在您继续从S3迁移到google cloud storage时进行调用

我认为google cloud storage尚不支持此功能,但您可以单独删除对象。正在跟踪。此外,可能有助于比较两个曲面并拨打电话。@ChrisWilcox谢谢。我使用了
s3.deleteObject
而不是
s3.deleteObjects
。您好@VikasKundu,问题现在解决了吗?@ChrisWilcox我对有助于解决问题的评论投了赞成票。请把它作为答案贴出来。