Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sharrajesh opened this issue Jun 9, 2015 · 0 comments

Comments

@sharrajesh
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant