简体   繁体   中英

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

This is my code to add tags to object during object creation.

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. So you either have to add it to your bucket policy or to your IAM user/role.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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