from qiniu import Auth, BucketManager
# 抓取文件到七牛
def fetch(url):
filename = str(time.time()).replace('.', '')
# 获取鉴权对象
auth = Auth(access_key, secret_key)
# 初始化BucketManager
bucket_manager = BucketManager(auth)
ret, info = bucket_manager.fetch(url, bucket_name, filename)
if info.status_code == 200:
file_url = bucket_domain + filename
return file_url
else:
return False
转载于:https://my.oschina.net/u/180293/blog/3002289