Boto3对象put方法加载0个字节 [英] Boto3 Object put method loads 0 bytes

查看:48
本文介绍了Boto3对象put方法加载0个字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下内容将一个空文件加载到我的s3存储桶中.为什么?

The following loads an empty file to my s3 bucket. Why?

df = pd.DataFrame([[1,2,3],[324,34,25], [463,23,43]])
out = df.to_csv(index=False) # unicode string (i'm in python 3)

s3 = boto3.resource('s3')
BUCKET = "MyBucketThatDefExistsAndIHaveAccessTo"
bucket = s3.Bucket(BUCKET)
obj = bucket.Object('TEST1')
obj.put(df.to_csv(index=False)) # loads an empty file "TEST1" to my bucket.

# I've also tried, but same result.
obj.put(bytes(df.to_csv(index=False), 'utf8')) 

推荐答案

应该不是,

obj.put(Body = df.to_csv(index = False))#将一个空文件"TEST1"加载到 我的水桶.

obj.put(Body=df.to_csv(index=False)) # loads an empty file "TEST1" to my bucket.

缺少主体命名参数.由于第一个参数是ACL,因此需要指定名称.

Missing Body named parameter. Since first parameter is ACL, you need to specify the name.

希望有帮助.

这篇关于Boto3对象put方法加载0个字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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