Skip to content

Instantly share code, notes, and snippets.

@pantaovay
Last active December 24, 2015 15:29
Show Gist options
  • Save pantaovay/6821078 to your computer and use it in GitHub Desktop.
Save pantaovay/6821078 to your computer and use it in GitHub Desktop.
Delete directory in Qiniu cloud storage using Python and Qiniu's Python SDK.
# -*- coding: utf-8 -*-
#author: pantaovay@gmail.com
#date: 2013/10/4
import qiniu.conf
import qiniu.rs
import qiniu.rsf
import sys.stderr
qiniu.conf.ACCESS_KEY = "<YOUR_APP_ACCESS_KEY>"
qiniu.conf.SECRET_KEY = "<YOUR_APP_SECRET_KEY>"
bucket_name = "<Your_Bucket_Name>"
rets, err = qiniu.rsf.Client().list_prefix(bucket_name, prefix="<Directory_Name>")
if err is not None:
sys.stderr.write('error: %s ' % err)
return
for item in rets[0].get('items'):
ret, err = qiniu.rs.Client().delete(bucket_name, item.get('key').encode('utf8'))
if err is not None:
sys.stderr.write('error: %s ' % err)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment