2017-04-23 10 views
0

사용자가 버튼을 클릭 할 때 파일을 다운로드하려고합니다. 코드 위응답 패키지를 사용하여 Safari에서 파일 다운로드 : 리소스로드 실패 : 프레임로드가 중단되었습니다.

bib_text = 'test' 

filename = 'test_file' 
response = make_response(bib_text) 
response.headers["Content-Disposition"] = "attachment; filename=%s.bib" % filename 
return response 

을 다음과 크롬에서 잘 작동하기 때문에 나는 응답 패키지와 파이썬 플라스크를 통해 구현되지만 사파리에서 자바 스크립트 콘솔은 나에게

Failed to load resource: Frame load interrupted 

대신에 .bib의 오류를 알려줍니다 파일을 .bib.html 파일로 다운로드 하시겠습니까? 어떤 일이 벌어지고 있는지 알 수 있습니까? Safari와 Chrome에서 작동하는 다른 방법이 있습니까?

답변

0

문제는 다음 헤더 사양을

response.headers["Cache-Control"] = "must-revalidate" 
response.headers["Pragma"] = "must-revalidate" 
response.headers["Content-type"] = "application/bib" 

콘텐츠 형식 사양을 추가함으로써 해결 될 수는 중요한 것이다