inventory entry confirmation - my distributions cahnge filter

This commit is contained in:
2025-07-28 16:05:36 +03:30
parent ba8a992b7b
commit e96da0ecc4
4 changed files with 95 additions and 15 deletions

View File

@@ -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