Last active
June 2, 2017 10:34
-
-
Save dmitry-mukhin/6be69dc779ca09b822d1 to your computer and use it in GitHub Desktop.
delete uploadcare files older than 14 days
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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() |
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
In case of old version
pyuploadcare
i.e. not from the master branch you just need to set: