Skip to content

Instantly share code, notes, and snippets.

@dmitry-mukhin dmitry-mukhin/delete.py
Last active Jun 2, 2017

Embed
What would you like to do?
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()
@zerc

This comment has been minimized.

Copy link

zerc commented Mar 10, 2016

For API verion 0.5:

FileList(stored=True, request_limit=500, starting_point=dt_cutoff, ordering='-datetime_uploaded')
@zerc

This comment has been minimized.

Copy link

zerc commented Mar 10, 2016

In case of old version pyuploadcare i.e. not from the master branch you just need to set:

conf.api_version = '0.4'
@dmitry-mukhin

This comment has been minimized.

Copy link
Owner Author

dmitry-mukhin commented Jun 2, 2017

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
You can’t perform that action at this time.