使用列表复制存储桶中的多个文件
copy multiple files in storage bucket using list
gsutil cp
命令有-I
option to copy multiple files using a list of file names from stdin
. Is there a way to do the same in python, preferable using a library like the official google storage client or gcfs/fsspec?还是只能遍历所有文件名并复制每个文件名?
使用gcsfs
master中的当前版本(即将发布),您可以将文件从内存或本地文件复制到GCS列表:
gcs.pipe({path1: content1, path2, content2}) # for in-memory bytes
gcs.put([local_path1, local_path2], [remote_path1, remote_path2]) # files
对于后者,您可以只提供一个远程路径,这将被假定为一个目录,并且远程文件将获得与本地相同的基本名称。
调用将并发处理,这可能比顺序上传快得多,尤其是对于小传输。
gsutil cp
命令有-I
option to copy multiple files using a list of file names from stdin
. Is there a way to do the same in python, preferable using a library like the official google storage client or gcfs/fsspec?还是只能遍历所有文件名并复制每个文件名?
使用gcsfs
master中的当前版本(即将发布),您可以将文件从内存或本地文件复制到GCS列表:
gcs.pipe({path1: content1, path2, content2}) # for in-memory bytes
gcs.put([local_path1, local_path2], [remote_path1, remote_path2]) # files
对于后者,您可以只提供一个远程路径,这将被假定为一个目录,并且远程文件将获得与本地相同的基本名称。
调用将并发处理,这可能比顺序上传快得多,尤其是对于小传输。