how to delete files from amazon s3 bucket? Ask Question

how to delete files from amazon s3 bucket? Ask Question

I need to write code in python that will delete the required file from an Amazon s3 bucket. I am able to connect to the Amazon s3 bucket, and also to save files, but how can I delete a file?

ベストアンサー1

Using boto3 (currently version 1.4.4) use S3.Object.delete().

import boto3

s3 = boto3.resource('s3')
s3.Object('your-bucket', 'your-key').delete()

おすすめ記事