Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

#!/usr/local/bin/python
import boto3 # requires "pip install boto3"

# Can enable some very verbose logging
import httplib
import logging
#httplib.HTTPConnection.debuglevel = 1
logging.basicConfig()
#logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True

# List https://support.cloud.caringo.com/tmp?prefix=versiontest/&versions
session = boto3.Session()
s3 = session.resource(service_name='s3',
endpoint_url='https://support.cloud.caringo.com',
aws_access_key_id='71c3845cca47a56323eba7fbdb923ffb',
aws_secret_access_key='secret')
bucket = s3.Bucket('tmp')

for i in bucket.object_versions.filter(Prefix='versiontest/'):
print i, i.is_latest
if not i.is_latest:
print 'Deleting old version: ' + str(i)
i.delete()

...