Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set CacheControl in the new Cloud Storage Api (Python)?

I'm following the guidelines and updating my code to use the new Cloud Storage API in GAE, i do need to set the cachecontrol headers, previously it was easy:

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

BUT, with the new API, the guidelines says that the "cache_control" is not available... I get this error when tried to put the cachecontrol inside the Options:

ValueError: option cache_control is not supported.

Tried with Cache-Control and the same error...

As usual, the documentation of the new API is not good.

Can someone help me how to set the cache headers in the new Cloud Storage API using PYTHON. In case is not possible, can I still use the old api for my project?

Thanks.

like image 419
Rene Marty Avatar asked Nov 02 '22 20:11

Rene Marty


1 Answers

You are right. As documented here, the open function only supports x-goog-acl and x-goog-meta headers.

Cache control is likely to be added in the near future to make migration easier. Please note that the main value of the GCS client lib is buffered read, buffered resumable write, and automatically retries to overcome transient errors. Many other simple REST operations on GCS (e.g cache, file copy, create bucket ...) can already be done by Google API Client. The "downside" of Google API Client is that since it doesn't come directly from/for App Engine, it does not have dev appserver support.

like image 97
Yey Avatar answered Nov 15 '22 05:11

Yey