如何在Boto(Amazon S3)的键中添加标签? [英] How can I add a tag to a key in boto (Amazon S3)?

查看:300
本文介绍了如何在Boto(Amazon S3)的键中添加标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试标记已上传到S3的密钥.在下面的相同内容中,我只是从字符串创建文件.获得密钥后,我不确定如何标记文件.我已经尝试了Tag和TagSet.

I am trying to tag a key that I've uploaded to S3. In the same below I just create a file from a string. Once I have they key, I'm not sure how to tag the file. I've tried Tag as well as TagSet.

from boto.s3.bucket import Bucket
from boto.s3.key import Key
from boto.s3.tagging import Tag, TagSet

k = Key(bucket)
k.key = 'foobar/somefilename'
k.set_contents_from_string('some data in file')

Tag(k, 'the_tag')

推荐答案

据我在文档中看到的,

As far as I can see in the docs, a setTags-method is only available on a bucket level and not on individual keys. Therefore you cannot set different tags to your uploaded file, but you would have to do this on the containing bucket.

这篇关于如何在Boto(Amazon S3)的键中添加标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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