Is there any way in Hybris to obtain all the bytes from a MediaModel ? When I want to instantiate a PdfReader , I need to pass either the Path of the File OR the ByteArrayInputStream. How can I transform the MediaModel into a Byte Array?
Asked
Active
Viewed 1,244 times
1 Answers
2
You can use MediaService
@Resource
private MediaService mediaService;
//...
final MediaModel mediaModel= mediaService.getMedia("mediaName");
final InputStream inputStream = mediaService.getStreamFromMedia(mediaModel);
Then you can pass InputStream or converting it to the format you want like ByteArrayInputStream
You can also convert it byte Array like this
byte[] bytes = IOUtils.toByteArray(is);

HybrisHelp
- 5,518
- 2
- 27
- 65
-
I am glad it helped. – HybrisHelp Oct 16 '19 at 13:09
-
HybrisHelp can you check this question please? https://stackoverflow.com/questions/58536975/flexible-search-query-union – Nexussim Lements Oct 24 '19 at 08:13