<legend id='lQvsO'><style id='lQvsO'><dir id='lQvsO'><q id='lQvsO'></q></dir></style></legend>

      <bdo id='lQvsO'></bdo><ul id='lQvsO'></ul>
    <i id='lQvsO'><tr id='lQvsO'><dt id='lQvsO'><q id='lQvsO'><span id='lQvsO'><b id='lQvsO'><form id='lQvsO'><ins id='lQvsO'></ins><ul id='lQvsO'></ul><sub id='lQvsO'></sub></form><legend id='lQvsO'></legend><bdo id='lQvsO'><pre id='lQvsO'><center id='lQvsO'></center></pre></bdo></b><th id='lQvsO'></th></span></q></dt></tr></i><div id='lQvsO'><tfoot id='lQvsO'></tfoot><dl id='lQvsO'><fieldset id='lQvsO'></fieldset></dl></div>
    <tfoot id='lQvsO'></tfoot>
  1. <small id='lQvsO'></small><noframes id='lQvsO'>

      使用 gcloud-python 在 Google Cloud Storage 中设置元数据

      Set metadata in Google Cloud Storage using gcloud-python(使用 gcloud-python 在 Google Cloud Storage 中设置元数据)
        1. <small id='f7r4u'></small><noframes id='f7r4u'>

            <legend id='f7r4u'><style id='f7r4u'><dir id='f7r4u'><q id='f7r4u'></q></dir></style></legend>
          • <i id='f7r4u'><tr id='f7r4u'><dt id='f7r4u'><q id='f7r4u'><span id='f7r4u'><b id='f7r4u'><form id='f7r4u'><ins id='f7r4u'></ins><ul id='f7r4u'></ul><sub id='f7r4u'></sub></form><legend id='f7r4u'></legend><bdo id='f7r4u'><pre id='f7r4u'><center id='f7r4u'></center></pre></bdo></b><th id='f7r4u'></th></span></q></dt></tr></i><div id='f7r4u'><tfoot id='f7r4u'></tfoot><dl id='f7r4u'><fieldset id='f7r4u'></fieldset></dl></div>
            • <bdo id='f7r4u'></bdo><ul id='f7r4u'></ul>
                <tbody id='f7r4u'></tbody>

              <tfoot id='f7r4u'></tfoot>
                本文介绍了使用 gcloud-python 在 Google Cloud Storage 中设置元数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试使用 gcloud-python 将文件上传到 Google Cloud Storage 并设置一些自定义元数据属性.为了尝试这个,我创建了一个简单的脚本.

                I am trying to upload a file to Google Cloud Storage using gcloud-python and set some custom metadata properties. To try this I have created a simple script.

                import os
                
                from gcloud import storage
                
                client = storage.Client('super secret app id')
                bucket = client.get_bucket('super secret bucket name')
                
                blob = bucket.get_blob('kirby.png')
                blob.metadata = blob.metadata or {}
                blob.metadata['Color'] = 'Pink'
                with open(os.path.expanduser('~/Pictures/kirby.png'), 'rb') as img_data:        
                    blob.upload_from_file(img_data)
                

                我可以上传文件内容.上传文件后,我可以从开发者控制台手动设置元数据并检索它.

                I am able to upload the file contents. After uploading the file I am able to manually set metadata from the developer console and retrieve it.

                我不知道如何以编程方式上传元数据.

                I can't figure out how to upload the metadata programmatically.

                推荐答案

                我们讨论过 在问题跟踪器上,它在实现中出现了一个错误",或者至少是让用户措手不及的东西.

                We discussed on the issue tracker and it surfaced a "bug" in the implementation, or at the very least something which catches users off guard.

                通过 blob.metadata 访问 metadata 是只读的.因此,当通过

                Accessing metadata via blob.metadata is read-only. Thus when mutating that result via

                blob.metadata['Color'] = 'Pink'
                

                它实际上并没有改变存储在 blob 上的元数据.

                it doesn't actually change the metadata stored on blob.

                目前的修复"是建立起来

                The current "fix" is to just build up

                metadata = {'Color': 'Pink'}
                blob.metadata = metadata
                

                这篇关于使用 gcloud-python 在 Google Cloud Storage 中设置元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                What happens when you compare 2 pandas Series(当你比较 2 个 pandas 系列时会发生什么)
                Quickly find differences between two large text files(快速查找两个大文本文件之间的差异)
                Python - Compare 2 files and output differences(Python - 比较 2 个文件和输出差异)
                Why do comparisions between very large float values fail in python?(为什么在 python 中非常大的浮点值之间的比较会失败?)
                Dictionary merge by updating but not overwriting if value exists(字典通过更新合并,但如果值存在则不覆盖)
                Find entries of one text file in another file in python(在python中的另一个文件中查找一个文本文件的条目)
                <i id='0wjgZ'><tr id='0wjgZ'><dt id='0wjgZ'><q id='0wjgZ'><span id='0wjgZ'><b id='0wjgZ'><form id='0wjgZ'><ins id='0wjgZ'></ins><ul id='0wjgZ'></ul><sub id='0wjgZ'></sub></form><legend id='0wjgZ'></legend><bdo id='0wjgZ'><pre id='0wjgZ'><center id='0wjgZ'></center></pre></bdo></b><th id='0wjgZ'></th></span></q></dt></tr></i><div id='0wjgZ'><tfoot id='0wjgZ'></tfoot><dl id='0wjgZ'><fieldset id='0wjgZ'></fieldset></dl></div>
              1. <tfoot id='0wjgZ'></tfoot>
              2. <legend id='0wjgZ'><style id='0wjgZ'><dir id='0wjgZ'><q id='0wjgZ'></q></dir></style></legend>

                      <bdo id='0wjgZ'></bdo><ul id='0wjgZ'></ul>

                          <small id='0wjgZ'></small><noframes id='0wjgZ'>

                            <tbody id='0wjgZ'></tbody>