0
간단한보기 클래스를 사용하여 해당 파일을 "강제 다운로드"합니다. 파일 다운로드 이름이 pk로 나옵니다. 나는 그것이 서버에있는 것처럼 원본 파일 이름이되고 싶습니다. 어떻게하면됩니까? 여기Django 다운로드 파일 이름
뷰의 코드를 장고
* 임 새로운 당신은 응답에 파일 이름을 설정해야
class GetFileContent(View):
def get(self,request, userName, pk):
user = User.objects.filter(username = userName)
filtered = File.objects.filter(pk = pk, published=True, file_owner = user)
data = filtered[0].content
return HttpResponse(data, content_type='application/force-download')
pass
Simeons Answer 외에도 아파치를 사용하고 루트 액세스 권한을 가지고 있다면 mod_xsendfile을 통해 파일을 전달하는 것이 좋습니다. – Jingo
아마존 s3을 사용합니다. –