In our organisation we need a custom object "Upload documents" where users should have ability to upload files of any size (No size limit ) and any format. All the documents should be saved in our document management system ( Already existing) which is a rest based service. We dont want to save documents in salesforce. When a document is saved, we want a link to be saved in salesforce ( In a field) where we can download the file. The link should also give the ability for external users(Non - salesforce users) to download the file even from outside salesforce. ( For instance if I will send the link of the document via normal email and when they click the link , users should be able to download the document).

Can you please suggest me if this is possible via apex coding or any app exchange apps or best possbile solution for this requirement. Please let me know if I'm not clear at any part.

PS: We have tried to do apex coding we came across following issues. 1) Max file size we can send via http call out is 12mb ( async) and 6mb ( sync) 2) we are not able to create a link where external users can download the file.

  • 1
    You'll never be able to implement a "no size limit" upload. Best you can do is 25MB I believe. If the max you can send is 12, maybe there's no difference.
    – Adrian Larson
    Commented Feb 24, 2016 at 15:02
  • 1
    If you're saying you're hosting files on another service and not Salesforce, might it not be an idea to work the other way round? Upload files to that and use a SOAP or REST call to create an Upload_Documents__c record with the link in there?
    – Dan Jones
    Commented Feb 24, 2016 at 15:05
  • @poet : yes but we are trying to upload docs via VF page in salesforce.
    – Shaan
    Commented Feb 24, 2016 at 15:21
  • Would be better to raise a case with salesforce and see if they can help/suggest anything. Commented Feb 24, 2016 at 15:27
  • @ShaileshDeshpande: I tried to raise a ticket initially while I was doing development. They confirmed http call out can't exceed 12mb. I am wondering if we can achieve in any other alternate way . via external applications.
    – Shaan
    Commented Feb 24, 2016 at 15:41

1 Answer 1


You can use the Salesforce AJAX Proxy to send requests of arbitrary size (I've tested this proxy to well over 250 MB). Any remote endpoint must first be configured in Setup > Security Controls > Remote Site Settings. This lets you read the files in JavaScript and send them to any allowed site.

Alternatively, you can create a form post to your server, with a redirect URL back to your Visualforce page when the upload is finished. Amazon S3, for example, supports this method with very large file uploads.

Or, if your API supports HTTP resume, you can repeatedly call PATCH methods in Apex Code to send 5 or 10 MB at a time (I used this technique with Amazon S3 after breaking the file into parts, sending each part one at a time). I used a simple file splitting technique to break the file up in to parts, stored as attachment records in salesforce, then call a batch process to complete the upload.

  • I saw the documentation of Salesforce AJAX Proxy and it is a client side code which runs on Javascript environment. So wouldn't it expose the the OAUTH token of the REST API (which we might be using to connect with external URI for upload) to users if they inspect the Javascript variable heap ? Commented Feb 24, 2016 at 15:56
  • I am not sure what kind of auth the external REST API is using, if it restricts access beyond what particular Salesforce user can do then I completely agree with your answer. I like AJAX Proxy more than latter approach because in latter data moves from User's browser -> Salesforce.com -> external site whereas in former it directly goes from User's browser -> external site Commented Feb 24, 2016 at 16:05
  • @karthikselva Certainly. In fact, all the user has to do is turn on Network Logging in Chrome, for example, and they could see the data without even digging through your JavaScript code/variables/etc. Each user should have their own, unique login to the CMS with proper security permissions, though. Hiding an OAuth token in some server code isn't security. Or, provide a special token that only allows uploads, etc.
    – sfdcfox
    Commented Feb 24, 2016 at 16:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .