google-app-engine - 如何在新的 Cloud Storage Api (Python) 中设置 CacheControl?

标签 google-app-engine google-cloud-storage

我正在遵循指南并更新我的代码以在 GAE 中使用新的 Cloud Storage API,我确实需要设置 cachecontrol header ,以前这很容易:

files.gs.create(filename, mime_type='image/png', acl='public-read', cache_control='public, max-age=100000, must-revalidate' )

但是,对于新的 API,指南指出“cache_control”不可用... 尝试将 cachecontrol 放在选项中时出现此错误:

ValueError: option cache_control is not supported.

尝试使用 Cache-Control 和同样的错误...

像往常一样,新 API 的文档并不好。

谁能帮助我如何使用 PYTHON 在新的 Cloud Storage API 中设置缓存 header 。万一不可能,我的项目还能使用旧的 api 吗?

谢谢。

最佳答案

你是对的。如记录here , open 函数仅支持 x-goog-acl 和 x-goog-meta header 。

在不久的将来很可能会添加缓存控制以使迁移更容易。请注意,GCS 客户端库的主要值(value)是缓冲读取、缓冲可恢复写入和自动重试以克服 transient 错误。 GCS 上的许多其他简单 REST 操作(例如缓存、文件复制、创建存储桶...)已经可以通过 Google API 完成 Client . Google API 客户端的“缺点”是,由于它不是直接来自 App Engine 或针对 App Engine,因此它没有开发应用程序服务器支持。

关于google-app-engine - 如何在新的 Cloud Storage Api (Python) 中设置 CacheControl?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17149817/

相关文章:

java - 如何将 iPad 图像数据传输到网络服务器?

android - 如何重命名 Firebase 存储中的文件夹 - Android Studio

python - 从 Kubernetes pod 将大文件上传到 Google Storage GCE

google-app-engine - 在测试环境中在 GAE (ndb) 和 GCE (gcloud.datastore) 之间共享数据存储

docker - 是否可以使用 docker 作为 golang 应用引擎标准环境的开发环境?

google-app-engine - 谷歌云存储 : download a file with a different name

google-cloud-storage - 即使经过验证也无法创建基于域的存储桶

java - 对于大文件(20G),Google Cloud Storage Java API 比 gsutil cp 慢得多

google-app-engine - 如何设置在 GCP Appengine 上运行的 GOOGLE_APPLICATION_CREDENTIALS

java - 将字符串转换为 Long (java) 和 Google 的 personID