I was doing this and worked perfectly fine:
def b64_image(filename):
with open("static/img/"+filename, 'rb') as f:
b64 = base64.b64encode(f.read())
return b64.decode('utf-8')
But now I uploaded the images to an S3 Bucket so I edited the code:
def b64_image(filename):
with open("https://mybucket.s3-sa-east-1.amazonaws.com/" + filename, 'rb') as f:
b64 = base64.b64encode(f.read())
return b64.decode('utf-8')
And I'm getting the fllowing error:
FileNotFoundError: [Errno 2] No such file or directory:
How can I make this code work? How can I make the code to look for the actual URL image? Thanks in advance.