Python 2.7 Google cloudstorage在尝试从bucket中删除时返回404未找到

Python 2.7 Google cloudstorage在尝试从bucket中删除时返回404未找到,python-2.7,google-app-engine,google-cloud-storage,Python 2.7,Google App Engine,Google Cloud Storage,我正试图通过cloudstorage api从Google云存储中删除一个文件(视频),但尽管该文件存在,但我收到以下错误: cloudstorage.delete('/catchamove-video/products/6411421952770048.mp4') *** NotFoundError: Expect status [204] from Google Storage. But got status 404. Path: '/catchamove-video/products/6

我正试图通过cloudstorage api从Google云存储中删除一个文件(视频),但尽管该文件存在,但我收到以下错误:

cloudstorage.delete('/catchamove-video/products/6411421952770048.mp4')

*** NotFoundError: Expect status [204] from Google Storage. But got status 404.
Path: '/catchamove-video/products/6411421952770048.mp4'.
Request headers: None.
Response headers: {'transfer-encoding': 'chunked', 'date': 'Sun, 07 May 2017 12:31:47 GMT', 'server': 'Development/2.0'}.
Body: ''.
Extra info: None.

bucket和文件都存在于控制台上。

我面临着同样的问题:通过RESTAPI删除文件夹时会得到404

经过一些测试,我发现如何删除GCP存储的文件夹-

必须删除文件夹中的所有文件(对象)、子文件夹中的文件以及子文件夹和文件夹。请注意,当删除空文件夹时,您可能仍然会得到“404未找到”(通常为204),只要忽略它,空文件夹就会被实际删除

示例:

curl -I -X DELETE -H "Authorization: Bearer <author_code>" https://www.googleapis.com/storage/v1/b/<bucket_name>/o/folder%2Fsub-folder%2Ffile1

curl -I -X DELETE -H "Authorization: Bearer <author_code>" https://www.googleapis.com/storage/v1/b/<bucket_name>/o/folder%2Fsub-folder%2Ffile2

curl -I -X DELETE -H "Authorization: Bearer <author_code>" https://www.googleapis.com/storage/v1/b/<bucket_name>/o/folder%2Fsub-folder%2F  #May get 204 or 404 response code

curl -I -X DELETE -H "Authorization: Bearer <author_code>" https://www.googleapis.com/storage/v1/b/<bucket_name>/o/folder%2F #May get 204 or 404 response code
curl-I-X DELETE-H“授权:承载”https://www.googleapis.com/storage/v1/b//o/folder%2Fsub-文件夹%2Ffile1
curl-I-X DELETE-H“授权:承载”https://www.googleapis.com/storage/v1/b//o/folder%2Fsub-文件夹%2Ffile2
curl-I-X DELETE-H“授权:承载”https://www.googleapis.com/storage/v1/b//o/folder%2Fsub-文件夹%2F#可能会获得204或404响应代码
curl-I-X DELETE-H“授权:承载”https://www.googleapis.com/storage/v1/b//o/folder%2F #可能会得到204或404响应代码

注意:URL中的“%2F”实际上是“/”字符

我们遇到了相同的问题。我们使用laravel和package,在服务帐户密钥json文件的帮助下,我们能够创建文件,但是当我们想要删除一个文件夹时,我们得到404错误。。。我们尝试将密钥中使用的所有存储权限添加到客户端电子邮件,还尝试将allUsers权限添加到服务帐户,幸运的是,您的情况不同-尝试删除文件夹,请参阅我知道GCP存储实际上没有文件夹,但在GCP控制台中,它允许创建一个空的“文件夹”。在某些情况下,你只想删除这个空文件夹,GCP认为它不是一个对象,所以返回404。