In this blog we will give an example how to load image from binary file in odoo using http controller function
so let us say that we made an integration with external api to get new customer data with is include image_file and we want to save this image into odoo database , so first we must create function that takes the image_file as an input and return the image as data (read the binary file), second we can pass the image data to image field in res.partner object in odoo to create new customer with image , and the function can be just as bellow
def load_image_from_binary_file(self, file):
return base64.b64encode(file.read())
No comments:
Post a Comment