http://mymagentohost.com/index.php/rest/V1/products/(productID)/media
This url is used to get the media for a particular product.
The response does not have the full image URL.
Response:
{
"id": 14,
"media_type": "image",
"label": "",
"position": 1,
"disabled": false,
"types": [
"image",
"small_image",
"thumbnail"
],
"file": "/p/w/pwp_sheet2.jpeg"
}
I am trying to access this URL from a ios app.
@userException You have the BASE URL because you access the API. Or i'm wrong?
but what should be the prefix for this URL ? if I want to download this image and show this in my app
Within Magento, you can use \Magento\Catalog\Model\Product\Media\Config::getBaseMediaUrl() to access the media base URL. However, since you are in an app, you will probably have to hardcode the prefix.
If the Webserver document root is configured to the pub/ directory within Magento, the media base URL for you would be http://mymagentohost.com/media/catalog/product.
If the Webserver document root is configured to the Magento base directory, the media base URL for you would be http://mymagentohost.com/pub/media/catalog/product.
That said, please refer to the Community Forums or Magento Stack Exchange site for technical questions. This issue tracker is only for bugs proposed changes.
If you think you have encountered a bug, please let us know, otherwise, if the question is answered for you, please close this issue.
Use the storeConfig API to get the base media url - http://devdocs.magento.com/swagger/index.html#!/storeStoreConfigManagerV1/storeStoreConfigManagerV1GetStoreConfigsGet
Most helpful comment
Within Magento, you can use
\Magento\Catalog\Model\Product\Media\Config::getBaseMediaUrl()to access the media base URL. However, since you are in an app, you will probably have to hardcode the prefix.If the Webserver document root is configured to the
pub/directory within Magento, the media base URL for you would behttp://mymagentohost.com/media/catalog/product.If the Webserver document root is configured to the Magento base directory, the media base URL for you would be
http://mymagentohost.com/pub/media/catalog/product.