Amazon S3 Python delete

import boto3
import sys
s3 = boto3.resource('s3')
bucket = s3.Bucket("simon-bucket")
prefix = str(sys.argv[1])
for object_summary in bucket.objects.filter(Prefix=prefix):
object_summary.delete()
print(object_summary.key)
for version_summary in bucket.object_versions.filter(Prefix=prefix):
version_summary.delete()
print(version_summary.key)
import boto3
import sys
s3 = boto3.resource('s3')
bucket = s3.Bucket("simon-bucket")
prefix = str(sys.argv[1])
for object_summary in bucket.objects.filter(Prefix=prefix):
if 'is^' in object_summary.key:
object_summary.delete()
elif 'file"' in object_summary.key:
object_summary.delete()
else:
object_summary.delete()
print(object_summary.key)
for version_summary in bucket.object_versions.filter(Prefix=prefix):
if 'is^' in version_summary.key:
version_summary.delete()
elif 'file"' in version_summary.key:
version_summary.delete()
else:
version_summary.delete()
print(version_summary.key)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store