Hello guys,
I have the situation where I need to pass product image url using API.
I am receiving product info from few vendors by AP, I need to display product image from external url on magento product page, any ideas how to implement this?
Solved! Go to Solution.
As always I ask first then I answer myself. Here's the solution I was looking for, code is in python:
from urllib.request import urlopen import base64 data=base64.b64encode(urlopen(" ").read()) imageEncoded=data.decode('utf-8')
then it passes to base64_encoded_data according to /rest/default/V1/products/{sku}t/media
{ "entry": { "mediaType": "image", "position": 0, "disabled": false, "types": [ "image", "small_image", "thumbnail", "swatch_image" ], "content":{ "base64_encoded_data" : "", "type": "image/jpeg", "name":"pic_name.jpg" } } }
As always I ask first then I answer myself. Here's the solution I was looking for, code is in python:
from urllib.request import urlopen import base64 data=base64.b64encode(urlopen(" ").read()) imageEncoded=data.decode('utf-8')
then it passes to base64_encoded_data according to /rest/default/V1/products/{sku}t/media
{ "entry": { "mediaType": "image", "position": 0, "disabled": false, "types": [ "image", "small_image", "thumbnail", "swatch_image" ], "content":{ "base64_encoded_data" : "", "type": "image/jpeg", "name":"pic_name.jpg" } } }