【问题标题】:CORS config on google bucket谷歌存储桶上的 CORS 配置
【发布时间】:2017-09-05 23:03:15
【问题描述】:

我正在尝试在谷歌存储桶上设置 CORS 配置。我指的是https://cloud.google.com/storage/docs/xml-api/put-bucket-cors。有人可以帮助我如何在 python 中使用这个请求。

【问题讨论】:

    标签: python cors google-cloud-platform google-cloud-storage


    【解决方案1】:

    您可能希望改用 JSON API,并使用 google-cloud-storage 库。 Bucket 的文档是here

    我还没有尝试过,但是类似:

    from google.cloud import storage
    
    bucket = storage.Client().get_bucket('bucket-id-here')
    bucket.cors = [{
      origin: ['*', ...],
      method: ['GET', ...],
      responseHeader: ['some-resp-header', ...],
      maxAgeSeconds: 86400, # one day
    }]
    bucket.patch()  # Send the update
    

    【讨论】:

    猜你喜欢
    • 2017-08-23
    • 2021-11-15
    • 2018-11-04
    • 2017-09-21
    • 2015-05-09
    • 2020-07-02
    • 2017-10-03
    • 2013-05-07
    • 1970-01-01
    相关资源
    最近更新 更多