Che*_*hez 6 google-app-engine python-2.7 google-cloud-storage
我试图通过 cloudstorage api 从 Google Cloud Storage 删除文件(视频),但尽管该文件存在,但出现以下错误:
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.
Run Code Online (Sandbox Code Playgroud)
存储桶和文件都显示在控制台上。
我面临同样的问题:通过 REST API 删除文件夹时收到 404。
经过一些测试,我弄清楚了如何删除 GCP 存储的文件夹 -
必须删除文件夹中的所有文件(对象)、子文件夹中的文件以及子文件夹和文件夹。请注意,删除空文件夹时,您可能仍然会收到“404 Not Found”(通常为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
Run Code Online (Sandbox Code Playgroud)
注意:URL 中的“%2F”实际上是“/”字符
| 归档时间: |
|
| 查看次数: |
3873 次 |
| 最近记录: |