0

I have created a bucket with DM using the below code

resources:
    - type: storage.v1.bucket
      name: test-bucket
      properties:
        project: my-project
        name: test-bucket

Now, when trying to create a folder structure inside the bucket (test-bucket-name\test), I am getting error. Please refer the sample code and the error message below.

resources:
- type: storage.v1.object
  name: test
  properties:
    project: my-project
    name: test
    bucket: test-bucket

Error:

message: '{"ResourceType":"storage.v1.object","ResourceErrorCode":"400","Resou
rceErrorMessage":{"code":400,"errors":[{"domain":"global","message":"Upload
    requests must include an uploadType URL parameter and a URL path beginning w
ith
    /upload/","reason":"wrongUrlForUpload","extendedHelp":"https://cloud.google.
com/storage/docs/json_api/v1/how-tos/upload"}],"message":"Upload
    requests must include an uploadType URL parameter and a URL path beginning w
ith
    /upload/","statusMessage":"Bad Request","requestPath":"https://www.googleapi
s.com/storage/v1/b/test-bucket/o","httpMethod":"POST"}}'

I tried to set the urlpath property but did not work.

Could anyone guide me this.

Radhika
  • 23
  • 1
  • 6

2 Answers2

1

You cannot create folders inside storage buckets. It is a flat storage. The only thing you can put in a storage bucket is objects (like files). These objects have names which may resemble a folder structure so that it becomes easy to view these objects in a UI or otherwise.

This makes cloud storage ideal for storing objects like images to be used in web pages, so that they can be retrieved fast without the overhead of folder structure.

Anurag
  • 876
  • 12
  • 16
1

Cloud Storage system has no notion of folders, folders created in the GCP Console are a convenience to help you organize objects in a bucket.

As a visual aid, the GCP Console shows folders with a folder icon image to help you distinguish folders from objects.
From within a bucket (or a folder in a bucket) you can create a new folder by clicking the Create Folder button.
Objects added to a folder appear to reside within the folder in the GCP Console.
In reality, all objects exist at the bucket level, and simply include the directory structure in their name.

For example, if you create a folder named drawer and add a file image.jpg to that folder, the GCP Console makes the file appear to exist in the folder.
In reality, there is no separate folder entity: the file simply exists in the bucket and has the name drawer/image.jpg.

Django
  • 151
  • 8