There is a requirement that when I am trying to send images/pdfs files from salesforce to external system, the external system is expecting the content in bytes. I have working code of JAVA but not sure how to convert that to Apex.
Anyone who can show an example of converting Blob of image/pdf files of salesforce to bytes in Apex?
Pasting the working JAVA code
InputStream inputStream = new FileInputStream(attachmentFilePath); long fileSize = new File(attachmentFilePath).length(); byte allBytes = new byte[(int) fileSize]; inputStream.read(allBytes); output.write(allBytes);
Tried to search at different places but don't think that salesforce has any default method to convert blob into byte in Apex.
Thanks in advance.