1

I need to pass an url of an ftp to be the product image by the magento api, can I do this? Something like

{
            "attribute_code": "image",
            "value": "https://upload.wikimedia.org/wikipedia/commons/5/5c/Alan-Walker-_Faded.jpg"
        }

I found the api to pass the image but it asks for a file and a base64 as below but this way it doesn't answer me.

{
"entry": {
"media_type": "image",
"label": "new_picture",
"types": [
  "image"
],
"file": "pic1.jpg",
"content": {
  "base64_encoded_data": "",
  "type": "image",
  "name": "pic1.jpg"
}
  }
}
  • 1
    You mean you want to pass product image url in rest api? – Rohan Hapani Aug 6 '20 at 8:00
  • Thanks for the answer, that's exactly what I need – Hudson Alves Triunfante Aug 6 '20 at 12:19
  • Is it useful for you? – Rohan Hapani Aug 7 '20 at 4:08
1

You need to start emulation using this below code :

$this->appEmulation->startEnvironmentEmulation($storeId, \Magento\Framework\App\Area::AREA_FRONTEND, true);

After that, you can get product image full url in your rest api.

For more details : Click Here

Hope, It will helpful for you.

0

Short answer: no

You'll need to send the base64 encoded image in the base64_encoded_data param

  • So do I necessarily need to save the image in the magento files and the bank? it doesn't seem to make sense ... – Hudson Alves Triunfante Aug 6 '20 at 12:40
  • That is the default way, another way is to have a cdn or another public image repository (not ftp), if that is the case, please tell me as I might have a solution. – Rus0 Aug 6 '20 at 19:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.