delete.py
684 Bytes
# -*- coding: utf-8 -*-
# flake8: noqa
from qiniu import Auth
from qiniu import BucketManager
def do_delete(access_key,secret_key,bucket_name,dst_file):
#初始化Auth状态
q = Auth(access_key, secret_key)
#初始化BucketManager
bucket = BucketManager(q)
#你要测试的空间, 并且这个key在你空间中存在
#删除bucket_name 中的文件 key
try:
ret, info = bucket.delete(bucket_name, dst_file)
assert ret == {}
print 'info:',info.text_body
except Exception as e:
print e.message
if 'no such key' in info.text_body:
return True
else:
return False
return True