bytes to string

This commit is contained in:
Achilles Rasquinha 2018-03-12 14:31:04 +05:30
parent f8a9678e73
commit 67132f775c

View file

@ -110,7 +110,7 @@ def save_url(file_url, filename, dt, dn, folder, is_private, df=None):
def get_uploaded_content():
# should not be unicode when reading a file, hence using frappe.form
if 'filedata' in frappe.form_dict:
if b"," in frappe.form_dict.filedata:
if "," in frappe.form_dict.filedata:
frappe.form_dict.filedata = frappe.form_dict.filedata.rsplit(",", 1)[1]
frappe.uploaded_content = base64.b64decode(frappe.form_dict.filedata)
frappe.uploaded_filename = frappe.form_dict.filename
@ -124,7 +124,7 @@ def save_file(fname, content, dt, dn, folder=None, decode=False, is_private=0, d
if isinstance(content, text_type):
content = content.encode("utf-8")
if b"," in content:
if "," in content:
content = content.split(",")[1]
content = base64.b64decode(content)