Skip to content

Instantly share code, notes, and snippets.

@dmitry-mukhin
Last active June 2, 2017 10:34
Show Gist options
  • Save dmitry-mukhin/6be69dc779ca09b822d1 to your computer and use it in GitHub Desktop.
Save dmitry-mukhin/6be69dc779ca09b822d1 to your computer and use it in GitHub Desktop.
delete uploadcare files older than 14 days
#!/bin/python
# installation:
# pip install pytz pyuploadcare==1.3.1
import pytz
from datetime import timedelta, datetime
from pyuploadcare import conf
from pyuploadcare.api_resources import FileList
MAX_LIFETIME = 14 # days
conf.pub_key = 'demopublickey'
conf.secret = 'demoprivatekey'
dt_cutoff = datetime.now(pytz.utc) - timedelta(days=MAX_LIFETIME)
if __name__ == '__main__':
for f in FileList(stored=True, request_limit=500, until=dt_cutoff):
print 'deleting {0}...'.format(f.uuid)
f.delete()
@dmitry-mukhin
Copy link
Author

this needs to be updated for batch delete

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment