是否有一个等效于getPublicUrl PHP方法的python ?
$public_url = CloudStorageTools::getPublicUrl("gs://my_bucket/some_file.txt", true);
我正在使用Google Cloud Client Library for Python存储一些文件,我正试图找出一种以编程方式获取我存储的文件的公共URL的方法.
有关如何构建网址,请参阅https://cloud.google.com/storage/docs/reference-uris.
对于公共URL,有两种格式:
http(s)://storage.googleapis.com/[bucket]/[object]
要么
http(s)://[bucket].storage.googleapis.com/[object]
例:
bucket = 'my_bucket' file = 'some_file.txt' gcs_url = 'https://%(bucket)s.storage.googleapis.com/%(file)s' % {'bucket':bucket, 'file':file} print gcs_url
输出这个:
https://my_bucket.storage.googleapis.com/some_file.txt
您需要使用get_serving_url
Images API.如该页面所述,您需要先调用create_gs_key()
以获取传递给Images API的密钥.