简体   繁体   English

这是如何使用 boto3 python 在 s3 中标记两个 object

[英]is this How to tag two object in s3 using boto3 python

This is my code to add tags to object during object creation.这是我在创建 object 期间向 object 添加标签的代码。

s3 = boto3.resource(
    's3',
    aws_access_key_id=ACCESS_KEY_ID,
    aws_secret_access_key=ACCESS_SECRET_KEY,
    config=Config(signature_version='s3v4')
)

s3.Bucket(pco_BUCKET_NAME).put_object(Key=f'{unique_id}/{username}.png', Body=pco_cropped_image, Tagging=f'unique_id={unique_id}')
s3.Bucket(pco_BUCKET_NAME).put_object(Key=f'{unique_id}/{username}.json', Body=pco_details, Tagging=f'unique_id={unique_id}')

This code gives me access denied error, but when I remove the tagging parameter it works fine.这段代码给了我访问被拒绝的错误,但是当我删除标记参数时它工作正常。

This happens probably because you have no s3:PutObjectTagging permissions.发生这种情况可能是因为您没有s3:PutObjectTagging权限。 So you either have to add it to your bucket policy or to your IAM user/role.因此,您必须将其添加到您的存储桶策略或您的 IAM 用户/角色中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM