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

<small id='Vc8gz'></small><noframes id='Vc8gz'>

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

    1. <tfoot id='Vc8gz'></tfoot>
      • <bdo id='Vc8gz'></bdo><ul id='Vc8gz'></ul>

        Google Cloud Storage - 将文件从一个文件夹移动到另一个文件夹 - 使用 Python

        Google Cloud Storage - Move file from one folder to another - By using Python(Google Cloud Storage - 将文件从一个文件夹移动到另一个文件夹 - 使用 Python)
      1. <small id='gE2e9'></small><noframes id='gE2e9'>

        <tfoot id='gE2e9'></tfoot>

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

                  本文介绍了Google Cloud Storage - 将文件从一个文件夹移动到另一个文件夹 - 使用 Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想将文件列表从谷歌存储移动到另一个文件夹:

                  I would like to move a list of file from google storage to another folder:

                  storage_client = storage.Client()
                  count = 0
                  
                  # Retrieve all blobs with a prefix matching the file.
                  bucket=storage_client.get_bucket(BUCKET_NAME)
                  # List blobs iterate in folder 
                  blobs=bucket.list_blobs(prefix=GS_FILES_PATH, delimiter='/') # Excluding folder inside bucket
                  for blob in blobs:
                  if fnmatch.fnmatch(blob.name, FILE_PREF):
                           WHAT CAN GO HERE?
                           count += 1   
                  

                  我在 Google 文档中找到的唯一有用信息是:

                  The only useful information which I found in Google Documentation is:

                  • https://cloud.google.com/storage/docs/重命名复制移动对象

                  根据本文档,唯一的方法是从一个文件夹复制到另一个文件夹并删除它.

                  By this documentation, the only method is to copy from one folder to another and delete it.

                  1. 有什么方法可以实际移动文件?
                  2. 根据前缀移动所有文件的最佳方法是什么,例如 *BLABLA*.csv

                  附:不想用

                  • "gsutil mv gs://[SOURCE_BUCKET_NAME]/[SOURCE_OBJECT_NAME]gs://[DESTINATION_BUCKET_NAME]/[DESTINATION_OBJECT_NAME]"

                  推荐答案

                  这可能是一个可能的解决方案,因为 google.cloud.storage 中没有 move_blob 函数:

                  This could be a possible solution, as there is no move_blob function in google.cloud.storage:

                  from google.cloud import storage  
                  
                  dest_bucket = storage_client.create_bucket(bucket_to)
                  source_bucket = storage_client.get_bucket(bucket_from)
                  blobs = source_bucket.list_blobs(prefix=GS_FILES_PATH, delimiter='/') #assuming this is tested
                  
                  for blob in blobs:
                      if fnmatch.fnmatch(blob.name, FILE_PREF): #assuming this is tested
                          source_bucket.copy_blob(blob,dest_bucket,new_name = blob.name)
                          source_bucket.delete_blob(blob.name)
                  

                  这篇关于Google Cloud Storage - 将文件从一个文件夹移动到另一个文件夹 - 使用 Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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中的另一个文件中查找一个文本文件的条目)
                    <tbody id='NZ0LK'></tbody>

                  <tfoot id='NZ0LK'></tfoot>

                    <small id='NZ0LK'></small><noframes id='NZ0LK'>

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

                      • <legend id='NZ0LK'><style id='NZ0LK'><dir id='NZ0LK'><q id='NZ0LK'></q></dir></style></legend>