简体   繁体   中英

Deleting file from s3 using pycharm boto3 library

How can I delete file with particular extension from s3 bucket using pycharm boto3 library. For example I have an s3 bucket having multiple files with different extension like '.txt', '.csv' etc. I want to create python script which will delete file from s3 having ".csv" extension only Please help

You can add a trigger on your S3 bucket with a suffix value as ".csv" to invoke a lambda where you can read the bucket and key from the event and use boto3's delete() method to delete the CSV file.

`import boto3

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

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