即将发送请求的视频文件发送给客户端以开始下载..
文件addrees(即哈希)正在提交给服务器,它应该返回文件下载...现在当我在浏览器中输入如下所示的URL时,它可以工作,
"
localhost:8000/api/v1/store/download/?q=e8000074ab4d,eJwLyygpKbDS18/JT07MycgvLrGyMDAw0C8tyMlPTNFPy8xJ1U9M1MstMOEqMODSAwB4gQ8P"
但是在客户端,当我发出相同的请求时,我会犯这样的错误:
Http failure response for (unknown url): 0 Unknown Error"
name: "HttpErrorResponse"
在firefox和chrome中我需要安装响应服务器
我的观点是这样的
class DownloadVideoAPI(APIView):
def get(self, request, ):
query = request.GET.get('q')
pre = query.split(",")
hash = pre[0]
dec = pre[1]
de_hash = decode_data(hash, dec)
if de_hash is not None:
resp = HttpResponse()
resp['Content-Disposition'] = 'attachment; filename=%s' % de_hash
resp['content_type'] = 'application/force-download'
return resp
else:
return Response(status.HTTP_400_BAD_REQUEST)
问题在哪里,我该如何解决?