django-sendfile icon indicating copy to clipboard operation
django-sendfile copied to clipboard

Our abc.tar.gz file sent using this django-sendfile was automatically getting unzipped by the browser

Open sharrajesh opened this issue 9 years ago • 0 comments

our code that was exhibiting the problem

return sendfile(request, remote_agent_installer, attachment=True, attachment_filename=filename, mimetype='application/octet-stream', add_encoding_header=False)

our work around: we added another param to not add content encoding.


Python27/Lib/site-packages/sendfile/init.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Python27/Lib/site-packages/sendfile/init.py b/Python27/Lib/site-packages/sendfile/init.py index da16a83..eaa0157 100644 --- a/Python27/Lib/site-packages/sendfile/init.py +++ b/Python27/Lib/site-packages/sendfile/init.py @@ -32,7 +32,7 @@ def _get_sendfile():

-def sendfile(request, filename, attachment=False, attachment_filename=None, mimetype=None, encoding=None): +def sendfile(request, filename, attachment=False, attachment_filename=None, mimetype=None, encoding=None, add_encoding_header=True): ''' create a response to send file using backend configured in SENDFILE_BACKEND

@@ -86,7 +86,7 @@ def sendfile(request, filename, attachment=False, attachment_filename=None, mime response['Content-Type'] = mimetype if not encoding: encoding = guessed_encoding

  • if encoding:
  • if encoding and add_encoding_header: response['Content-Encoding'] = encoding

return response

sharrajesh avatar Jun 09 '15 18:06 sharrajesh