장고에있는 내 웹 페이지 중 하나에 다운로드 링크가 있습니다. 75MB의 오디오 파일을 다운로드 할 때 오디오는 0 바이트 만 다운로드하지만 아무것도 다운로드하지 않습니다. 내가 아파치 서버를 사용django를 사용하여 다운로드하는 방법은 무엇입니까?
from django.core.servers.basehttp import FileWrapper
import mimetypes
rec_file = settings.WEB_PATH + "/media/recording/" + filename
wrapper = FileWrapper(open(rec_file, "r"))
contentType = mimetypes.guess_type(rec_file)[0]
response = HttpResponse(wrapper, mimetype = "application/force-download")
response['Content-Length'] = os.path.getsize(rec_file)
response['Content-Disposition'] = "attachment; filename=" + filename
return response
:
이 내 코드입니다. 아무도 내게 솔루션을 말할 수 있습니까?
이상한 ... 프로덕션에서 사용되는 거의 동일한 코드가 있고 작동합니다 ... – Nemeth