In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article shows you how to use the code to get the product pictures displayed in Hybris Commerce, the content is concise and easy to understand, it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Use the following API to get the details of the product master data in the Hybris Commerce system:
Https://:9002/rest/v2/electronics/products/300938?fields=FULL
The url of the image is contained in the field images.url, as shown below:
After adding the full domain name, the url can be accessed directly in the browser: https://:9002/rest/v2/medias/?context=bWFzdGVyfGltYWdlc3wxMzkzNnxpbWFnZS9qcGVnfGltYWdlcy9oMGQvaDVhLzg3OTYyMTQwOTk5OTguanBnfDIwNTM4ZDc0YjQ5YjQzNGE0ZTJlMDZlNmU2NGNmOTI4MzAwOGM1Y2UwNTkyZmJkMzczMTljN2I2N2MzZmY3N2I
Just because there is a problem with the certificate setting of my server running Hybris commerce, the following error was reported when accessing this url in Wechat:
This address is the IP address, please use the domain name to visit the website:
You can access this picture by entering the IP address directly in the mobile browser:
The value of context in url: bWFzdGVyfGltYWdlc3wxMzkzNnxpbWFnZS9qcGVnfGltYWdlcy9oMGQvaDVhLzg3OTYyMTQwOTk5OTguanBnfDIwNTM4ZDc0YjQ5YjQzNGE0ZTJlMDZlNmU2NGNmOTI4MzAwOGM1Y2UwNTkyZmJkMzczMTljN2I2N2MzZmY3N2I
This value is the value after base64 encoding, which is decoded using the commonly used base64 and then viewed:
It is the Administration information that stores pictures on some Hybris systems.
Considering that the url is returned directly to the consumer side, due to the certificate problem, it is not convenient for the front end to display this image, so we decided to return the base64 encoded content of the picture to the front end instead of url.
So use the following simple code to get the base64 encode code value of the image according to url:
RestTemplate template = new RestTemplate (); String url = "https://:9002/rest/v2/medias/?context=bWFzdGVyfGltYWdlc3wxMzkzNnxpbWFnZS9qcGVnfGltYWdlcy9oMGQvaDVhLzg3OTYyMTQwOTk5OTguanBnfDIwNTM4ZDc0YjQ5YjQzNGE0ZTJlMDZlNmU2NGNmOTI4MzAwOGM1Y2UwNTkyZmJkMzczMTljN2I2N2MzZmY3N2I"; byte [] imageBytes = template.getForObject (url, byte [] .class); System.out.println (" response size: "+ imageBytes.length); String base64Image = Base64.getEncoder () .encodeToString (imageBytes); System.out.println (" content: "" + base64Image)
Paste the generated base64 encoding to the online base64 decoding website and successfully restore it to an image:
The above is how to use the code to get the product pictures displayed in Hybris Commerce. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.