使用 wget 等命令行实用程序从 google 云存储下载 public 数据目录
Downloading public data directory from google cloud storage with command line utilities like wget
我想从 google 云存储下载公开可用的数据。但是,因为我需要在Python3.x环境下,所以无法使用gsutil。我可以使用 wget as
下载单个文件
wget http://storage.googleapis.com/path-to-file/output_filename -O output_filename
但是,像
这样的命令
wget -r --no-parent https://console.cloud.google.com/path_to_directory/output_directoryname -O output_directoryname
似乎不起作用,因为他们只是下载该目录的索引文件。基于一些初始尝试的 rsync 或 curl 尝试也不会。知道如何将 google 云存储上的公开可用数据作为目录下载吗?
您上面提到的方法不起作用,因为Google Cloud Storage 没有真正的"directories"。例如,"path/to/some/files/file.txt" 是该对象的全名。一个类似命名的对象,"path/to/some/files/file2.txt",恰好共享相同的命名前缀。
至于如何获取这些文件:GCS API(XML 和 JSON)允许您针对父存储桶执行对象列表,指定前缀;在这种情况下,您希望所有对象都以前缀 "path/to/some/files/" 开头。然后,您可以为响应正文中指定的每个对象发出单独的 HTTP 请求。话虽如此,您可能会发现通过 GCS 客户端库之一(例如 the Python library.
更容易做到这一点
此外,gsutil 目前有 a GitHub issue open to track adding support for Python 3。
我想从 google 云存储下载公开可用的数据。但是,因为我需要在Python3.x环境下,所以无法使用gsutil。我可以使用 wget as
下载单个文件wget http://storage.googleapis.com/path-to-file/output_filename -O output_filename
但是,像
这样的命令wget -r --no-parent https://console.cloud.google.com/path_to_directory/output_directoryname -O output_directoryname
似乎不起作用,因为他们只是下载该目录的索引文件。基于一些初始尝试的 rsync 或 curl 尝试也不会。知道如何将 google 云存储上的公开可用数据作为目录下载吗?
您上面提到的方法不起作用,因为Google Cloud Storage 没有真正的"directories"。例如,"path/to/some/files/file.txt" 是该对象的全名。一个类似命名的对象,"path/to/some/files/file2.txt",恰好共享相同的命名前缀。
至于如何获取这些文件:GCS API(XML 和 JSON)允许您针对父存储桶执行对象列表,指定前缀;在这种情况下,您希望所有对象都以前缀 "path/to/some/files/" 开头。然后,您可以为响应正文中指定的每个对象发出单独的 HTTP 请求。话虽如此,您可能会发现通过 GCS 客户端库之一(例如 the Python library.
更容易做到这一点此外,gsutil 目前有 a GitHub issue open to track adding support for Python 3。