Hi ,
I am able to get the PDF file path as /content/dam/folder1/folder2/pdf.pdf, not I want to read the pdf data and convert it into the byteArray.
I am not able to read the PDF file from DAM asset as we read it simple from local system. kindly revert.
Thank You
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hi,
You could follow the next steps:
- Get the asset rendition
- From the rendition, you get the InputStream
- Then you convert your InputStream to ByteArray
Something like this:
Resource rr = resourceResolver.getResource(pathToYourAsset);
Asset asset = rr.adaptTo(Asset.class);
Rendition originalRendition = asset.getOriginal();
InputStream is = originalRendition.getStream();
byte[] bytes = IOUtils.toByteArray(is);
Please check these links for more details:
https://stackoverflow.com/questions/1264709/convert-inputstream-to-byte-array-in-java
https://www.baeldung.com/convert-input-stream-to-array-of-bytes
Hope this helps
Hi,
You could follow the next steps:
- Get the asset rendition
- From the rendition, you get the InputStream
- Then you convert your InputStream to ByteArray
Something like this:
Resource rr = resourceResolver.getResource(pathToYourAsset);
Asset asset = rr.adaptTo(Asset.class);
Rendition originalRendition = asset.getOriginal();
InputStream is = originalRendition.getStream();
byte[] bytes = IOUtils.toByteArray(is);
Please check these links for more details:
https://stackoverflow.com/questions/1264709/convert-inputstream-to-byte-array-in-java
https://www.baeldung.com/convert-input-stream-to-array-of-bytes
Hope this helps
Thank You so much , it's working.
Views
Replies
Total Likes
Views
Likes
Replies