inventory entry confirmation - my distributions cahnge filter
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
from django.core.files.base import ContentFile
|
||||
import base64
|
||||
|
||||
|
||||
def base64_to_image_file(base64_string, filename="image.jpg"):
|
||||
""" convert base64 to image, pdf,..... """
|
||||
|
||||
img_format, img_str = base64_string.split(';base64,') # split before & after of ';base64,'
|
||||
ext = img_format.split('/')[-1] # split format of file
|
||||
return ContentFile(base64.b64decode(img_str), name=f"{filename}.{ext}"), ext
|
||||
|
||||
Reference in New Issue
Block a user