You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

19 lines
520 B

import base64
from django.conf import settings
def decode_base64(my_str, upload_to):
if "data:" in my_str:
my_str = my_str[my_str.index("base64,")+7:]
path = "%s/%s" % (settings.MEDIA_ROOT, upload_to)
url = "%s%s" % (settings.MEDIA_URL, upload_to)
with open(path, "wb") as fh:
fh.write(base64.b64decode(my_str))
return url
return my_str
def get_real_name(array, elem):
for i, j in array:
if i and (i == elem or j == elem):
return i