• Tirthankar Dastidar
  • 0 Points
  • Member since 2015

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
  • 0
Hello, I have a requirement to send Attachment file data to a third party system. Currently I am quering each attachment in a separate batch and then convert the blob data to base64 string to form a specific XML for the third party API to accept. Then issueing a apexcallout to send the attachment data to that system.
string requestBody = '<Job><InputType>'+attachment.ContentType.substringAfter('/')+'</InputType><InputURL></InputURL><InputBlob type="binary">'+EncodingUtil.base64Encode(attachment.Body)+'</InputBlob></Job>

This is working fine although the problem is with large attachments. When in an average, an attachment is of size around 7MB, the base64 string is hitting the System.heaplimitexception of 12MB and the callout fails. Salesforce supports to attach a file upto 25MB size, so i have to support that file size. But I am severely limited by the heaplimit exception. I tried the

o send the blob data directly to external system but that again it has only 3MB of limit. Could you please help me to show any solution to get around it?
Thanks in advance.