- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2021
11:27 PM
07-27-2021
11:27 PM
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.
Labels:
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2021
02:53 AM
07-28-2021
02:53 AM
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" } } }
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2021
02:53 AM
07-28-2021
02:53 AM
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" } } }