mirror of
https://github.com/lucaspalomodevelop/eventcally.git
synced 2026-03-13 08:09:37 +00:00
19 lines
428 B
Python
19 lines
428 B
Python
import base64
|
|
|
|
from project.models import Image
|
|
|
|
|
|
def upsert_image_with_data(image, data, encoding_format="image/jpeg"):
|
|
if image is None:
|
|
image = Image()
|
|
|
|
image.data = data
|
|
image.encoding_format = encoding_format
|
|
|
|
return image
|
|
|
|
|
|
def upsert_image_with_base64_str(image, base64_str, encoding_format):
|
|
data = base64.b64decode(base64_str)
|
|
return upsert_image_with_data(image, data, encoding_format)
|