Delete files in uploadcare — python

VictorManuel LaFra
Sep 5, 2018 · 1 min read

If you have many files in your uploadcare and you want delete this files, you can try delete with this script

First make to the file, delete.py for example.

import pytz
from datetime import timedelta, datetime
import time
from pyuploadcare import conf
from pyuploadcare.api_resources import FileList, FilesStorage
MAX_LIFETIME = 30 # days
conf.pub_key = ‘your pub key’
conf.secret = ‘your secret key’
//In date time you can put the date.. for example i want delete until september 25 dt_cutoff = datetime(2018, 8, 25, 13, 39, 23 ,tzinfo=pytz.utc) — timedelta(days=MAX_LIFETIME)if __name__ == ‘__main__’:uuid_list = [f.uuid for f in FileList(starting_point=dt_cutoff,
ordering=’-datetime_uploaded’,
stored=True,
request_limit=500)]
ts1 = time.time()
fs = FilesStorage(uuid_list)
fs.delete()
ts2 = time.time()
print (“Operation completed”)
  • The pub key and secret, these are on the site with your acount
  • In API keys

And fine!

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade