0

I am using html5 FileReader + ajax toolkit + soap API in my Visualforce page to upload a single file as ContentVersion. I'm able to upload files up to 37435519 bytes pdf file but I get this error in my chrome console when I upload a 48mb pdf file:

Maximum size of request reached. Maximum size of request is 52428800 bytes

which clearly is saying the limit is 50mb.

  1. My main question is what is the file-size limit on the way I'm doing it?
  2. Is there a better way to upload a file from a VisualForce page that gives me a higher file-size limit?

Here is a screenshot of the console error.

1 Answer 1

1

My main question is what is the file-size limit on the way I'm doing it?

The AJAX Toolkit uses SOAP API calls. SOAP calls always have a maximum limit of 50MB. However, it is also XML-based, which restricts the available characters you can use, so the file has to be Base-64 encoded. This puts the final limit at around 37 MB of binary data, as you've observed. The SOAP protocol itself consumes some bytes, so the actual limit is going to depend on several factors, like any extra headers you might use, but should be somewhere around 37,440,000 bytes, as you've observed.

Is there a better way to upload a file from a VisualForce page that gives me a higher file-size limit?

Use the REST API to upload up to 2GB. You can read more about it in Insert or Update Blob Data, found in the REST API documentation. Depending on what you're uploading, there are different parameters/headers/etc you may need. The examples are kind of lengthy, so I'm not including them here, but it should be pretty self-explanatory if you look at the documentation.

0

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.