django return file over HttpResponse - file is not served correctly

后端 未结 3 473
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-29 07:40

I want to return some files in a HttpResponse and I\'m using the following function. The file that is returned always has a filesize of 1kb and I do not know why. I can open

3条回答
  •  别那么骄傲
    2020-12-29 08:05

    Could it be that the file contains some non-ascii characters that render ok in production but not in development?

    Try reading the file as binary:

    fsock = open(file_path,"rb")
    

提交回复
热议问题