是否可以不通过boto3下载而获取S3文件的内容? [英] Is it possible to get the contents of an S3 file without downloading it using boto3?

查看:106
本文介绍了是否可以不通过boto3下载而获取S3文件的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究从Redshift数据库中转储文件的过程,并且希望不必在本地下载文件来处理数据.我看到Java有一个StreamingObject类,该类可以满足我的要求,但在boto3中却没有看到任何类似的东西.

I am working on a process to dump files from a Redshift database, and would prefer not to have to locally download the files to process the data. I saw that Java has a StreamingObject class that does what I want, but I haven't seen anything similar in boto3.

推荐答案

如果您有一个mybucket S3存储桶,其中包含一个beer密钥,这是下载和获取值而不将其存储在本地的方法文件:

If you have a mybucket S3 bucket, which contains a beer key, here is how to download and fetch the value without storing it in a local file:

import boto3
s3 = boto3.resource('s3')
print s3.Object('mybucket', 'beer').get()['Body'].read()

这篇关于是否可以不通过boto3下载而获取S3文件的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆