1

I am trying to do various things with folders after creation, such as move ad delete.

However, I am only getting 404 Not Found errors, despite the folders existing!

I am using the following code to try and delete a folder

try {
    $this->service->objects->delete($bucket, $file);
} catch (Google_Service_Exception $e) {
    syslog(LOG_ERR, $e);
}

And I am passing the correct bucket name (e.g. bucket-name.appspot.com) along with a folder path (e.g. main_folder/sub_folder/another_folder_here)

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
Mr Pablo
  • 4,109
  • 8
  • 51
  • 104

1 Answers1

0

Google Cloud Storage uses a flat namespace of object names. The service has no notion of a "folder". See some documentation here: https://cloud.google.com/storage/docs/cloud-console#_creatingfolders

If you want to delete everything underneath a prefix, you'll have to list all objects underneath that prefix and then issue individual delete requests.

jterrace
  • 64,866
  • 22
  • 157
  • 202