GS Python ライブラリで提供されているコード例を使用して、Google Cloud Storage から大きなファイル (2.5 GB) をダウンロードしようとしています。これは、小さなファイルでは問題なく機能します (1 ~ 2 KB のファイルでテストしました)。Windows 7 で Python 2.7.5 を使用しています。
dest_dir = c:\\downloadfolder
networkbucket = bucketname
uri = boto.storage_uri(networkbucket,'gs')
for obj in uri.get_bucket():
print obj.name
name=str(obj.name)
local_dst_uri = boto.storage_uri(os.path.join(dest_dir, name),'file')
object_contents = StringIO.StringIO()
src_uri = boto.storage_uri(networkbucket + '/' + name, 'gs')
src_uri.get_key().get_file(object_contents)
object_contents.seek(0)
local_dst_uri.new_key().set_contents_from_file(object_contents)
object_contents.close()
メモリ エラーが発生します。
Traceback (most recent call last):
File "C:\folder\GS_Transfer.py", line 52, in <module>
src_uri.get_key().get_file(object_contents)
File "C:\gsutil\third_party\boto\boto\gs\key.py", line 165, in get_file
query_args=query_args)
File "C:\gsutil\third_party\boto\boto\s3\key.py", line 1455, in _get_file_internal
for bytes in self:
File "C:\gsutil\third_party\boto\boto\s3\key.py", line 364, in next
data = self.resp.read(self.BufferSize)
File "C:\gsutil\third_party\boto\boto\connection.py", line 414, in read
return httplib.HTTPResponse.read(self, amt)
File "C:\Python27\lib\httplib.py", line 567, in read
s = self.fp.read(amt)
File "C:\Python27\lib\socket.py", line 400, in read
buf.write(data)
MemoryError: out of memory
gsutil.py cp を使用して、コマンド ラインからファイルを正常にダウンロードできます。しかし、このコードを修正するために何をすべきかわからない? 部分的にダウンロードする方法を見つけようとしていますが、方法がわかりません。