I am using the component found here: https://gist.github.com/peterknolle/bb4b7ac63f67f66c32b0

The issue I am running into is that the image will upload and save in Salesforce, but images larger than 750K seem to cause problems and just show up grey/corrupted as attachments.

Smaller images will upload without a problem.

Viewing console logs and debug logs I can see the entire chunking process is completing, and the attachment makes it to Salesforce, it just corrupts the attachment during the upload process.

Has anyone run into this before and can suggest a fix?


You're going to want to use <lightning:input type='file'> once Spring '17 drops. Here's a link to the relevant section of the notes.

There are several limits that are coming in to play that cause that limit of 750kb. Your file gets uploaded in chunks, each chunk can be 1 million characters max (Remote Action Request Size Limit). A chunk is actually a string, so you're appending to that string and then doing a dml update. The maximum size of a string in Apex is 6 million characters. The string is also base64 encoded, so your data gains a bit of bloat from that.

  • I appreciate the response! I am curious if anyone knows if this is potentially related to something other than governor limits. I did notice heap size errors in dev console, but with smaller chunk sizes I can see it upload completely without any errors. (Except for the corrupted image). Thanks in advance! – Steve Jonson Feb 1 '17 at 17:51
  • 1
    How would you submit the form with the <lightning:input type='file'>? Won't the file(s) will still have to be encoded to string and chunked? – Jan Julian Feb 17 '17 at 4:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.