如何使用Boto在S3中设置元数据? [英] How to set metadata in S3 using boto?
本文介绍了如何使用Boto在S3中设置元数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将文件推送到S3期间设置元数据.
I am trying to set metadata during pushing a file to S3.
这是它的样子:
def pushFileToBucket(fileName, bucket, key_name, metadata):
full_key_name = os.path.join(fileName, key_name)
k = bucket.new_key(full_key_name)
k.set_metadata('my_key', 'value')
k.set_contents_from_filename(fileName)
由于某种原因,这会在set_metadata上抛出错误:
For some reason this throws error at set_metadata saying :
boto.exception.S3ResponseError: S3ResponseError: 403 Forbidden
<?xml version="1.0" encoding="UTF-8"?><Error><Code>SignatureDoesNotMatch</Code></Error>
当我删除此 set_metadata
部分时,文件将被正确存储.不知道我在做什么错.如果访问密钥无效,则无论如何都不会保存文件!
And when I remove this set_metadata
part, the file is getting stored correctly.
Not sure what I am doing wrong. If the access key was invalid, then it wouldn't have saved the file anyway!
推荐答案
已解决此问题.显然,我们在元数据键名称中不能包含下划线
.
Got this fixed. Apparently we cannot have an underscore
in the metadata key name.
这篇关于如何使用Boto在S3中设置元数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文