使用Deployment Manager在Google存储桶中创建文件夹

时间:2020-09-22 10:47:04

标签: google-cloud-platform google-cloud-storage

尝试在存储桶(test-bucket123 \ test)内创建文件夹结构时,出现错误。请参考下面的示例代码和错误消息。

resources:
- name: mybucketname
  type: storage.v1.bucket
  properties:
    project: projectID
    location: {{properties['region']}}
    storageClass: {{properties['storageClass']}}
    versionning:
      enabled: false

- type: storage.v1.object
  name: test
  properties:
    project: projectID
    name: test
    bucket: mybucketname
ERROR: (gcloud.deployment-manager.deployments.create) Error in Operation [operation-1600770967871-5afe488e8201e-2cbd6491-ae9d363b]: errors:
- code: RESOURCE_ERROR
  location: /deployments/my-deployment/resources/test
  message: '{"ResourceType":"storage.v1.object","ResourceErrorCode":"400","ResourceErrorMessage":{"code":400,"errors":[{"domain":"global","message":"Uploads
    must be sent to the upload URL. Re-send this request to https://storage.googleapis.com/upload/storage/v1/b/mybucketname/o?name=test","reason":"wrongUrlForUpload"}],"message":"Uploads
    must be sent to the upload URL. Re-send this request to https://storage.googleapis.com/upload/storage/v1/b/mybucketname/o?name=test","statusMessage":"Bad
    Request","requestPath":"https://storage.googleapis.com/storage/v1/b/mybucketname/o","httpMethod":"POST"}}'

我试图设置urlpath属性,但是没有用。

有人可以指导我吗?

1 个答案:

答案 0 :(得分:0)

该文件夹在Google存储空间中不存在!这是一个存储桶,所有对象都在存储桶中,没有文件夹。您可以使用路径前缀this/is/a/folder.json来命名对象。但这只是为了人类的表现和可读性。

您可以尝试一下。在Storage中创建一个带有路径的文件,您将在控制台中看到目录。删除文件(仅文件),所有目录都消失!

相关问题