获取文件的公共URL - Google云端存储 - App Engine(Python)

 保定联通员工 发布于 2023-02-07 11:54

是否有一个等效于getPublicUrl PHP方法的python ?

$public_url = CloudStorageTools::getPublicUrl("gs://my_bucket/some_file.txt", true);

我正在使用Google Cloud Client Library for Python存储一些文件,我正试图找出一种以编程方式获取我存储的文件的公共URL的方法.

2 个回答
  • 有关如何构建网址,请参阅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

    2023-02-07 11:56 回答
  • 您需要使用get_serving_urlImages API.如该页面所述,您需要先调用create_gs_key()以获取传递给Images API的密钥.

    2023-02-07 11:57 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有