【问题标题】:Delete gcp bucket objects using s3 api使用 s3 api 删除 gcp 存储桶对象
【发布时间】:2023-03-21 12:10:01
【问题描述】:

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


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

assetsToDelete 的值为

  {
    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 存储桶中删除。

【问题讨论】:

标签: node.js google-cloud-platform aws-sdk aws-sdk-js


【解决方案1】:

截至发帖时,Google Cloud Storage 不支持多对象删除。

也就是说,您可以删除单个对象。 如果你想跟踪这个添加,你可以查看https://issuetracker.google.com/issues/162653700

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-03-20
    • 2013-08-23
    • 2012-05-16
    • 1970-01-01
    • 2020-11-09
    • 1970-01-01
    • 2010-10-16
    • 2017-03-06
    相关资源
    最近更新 更多