Skip to content

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

@sharrajesh

Description

@sharrajesh

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions