xxxxxxxxxx
import base64
# Read the file as binary data
with open('path/to/file.jpg', 'rb') as file:
file_data = file.read()
# Encode the file data into Base64 bytes
base64_data = base64.encodebytes(file_data)
# Create the Base64 data URL
data_url = f'data:image/jpeg;base64,{base64_data.decode()}'
print(data_url)