七牛云上传博客
#注册七牛云后获取属于自己的key值,通过Key值来获取tokien
class QiNiuView(APIView): def get(self,request): #需要填写你的 Access Key 和 Secret Key access_key = 'JR8b2pQ3Xz1sYQ5zn0E0qRzHxFPGYPB2GDqAS2KX' secret_key = 'vJQDS5rcvbSizskyr8fHCh-O6oFNE42QZghXXyoO' #构建鉴权对象 q = Auth(access_key, secret_key) #要上传的空间 bucket_name = 'syllllllll' #上传后保存的文件名 key = 'http://qi68m15bf.hb-bkt.clouddn.com/%E4%B8%83%E7%89%9B%E4%BA%91.mp4' #生成上传 Token,可以指定过期时间等 # 上传策略示例 # https://developer.qiniu.com/kodo/manual/1206/put-policy policy = { # 'callbackUrl':'https://requestb.in/1c7q2d31', # 'callbackBody':'filename=$(fname)&filesize=$(fsize)' # 'persistentOps':'imageView2/1/w/200/h/200' } #3600为token过期时间,秒为单位。3600等于一小时 token = q.upload_token(bucket_name, key, 3600, policy) return Response({"token":token,"code":"200","msg":"good"})
#注册路游 path('qntoken/',QiNiuView.as_view())
做最野的狼