Browse Source

Add binary mime type in response.py

version-14
Manas Solanki 8 years ago
parent
commit
8bcd479831
1 changed files with 9 additions and 1 deletions
  1. +9
    -1
      frappe/utils/response.py

+ 9
- 1
frappe/utils/response.py View File

@@ -36,7 +36,8 @@ def build_response(response_type=None):
'download': as_raw,
'json': as_json,
'page': as_page,
'redirect': redirect
'redirect': redirect,
'binary': as_binary
}

return response_type_map[frappe.response.get('type') or response_type]()
@@ -68,6 +69,13 @@ def as_json():
response.data = json.dumps(frappe.local.response, default=json_handler, separators=(',',':'))
return response

def as_binary():
response = Response()
response.mimetype = 'application/octet-stream'
response.headers[b"Content-Disposition"] = ("filename=\"%s\"" % frappe.response['filename'].replace(' ', '_')).encode("utf-8")
response.data = frappe.response['filecontent']
return response

def make_logs(response = None):
"""make strings for msgprint and errprint"""
if not response:


Loading…
Cancel
Save