[SalesForce] Correct approach uploading File using REST API (file size 100 MB)

Looking for best REST API to upload a file to a record with at least file size 100MB?

I have created custom REST API handles POST call, inserts both ContentVersion, ContentDocumentLink records (Base 64 content in request body) manually. But using custom API not able to upload(not able to test) file size more than 23 MB.

other way using with standard salesforce REST API, (/services/data/v35.0/chatter/feed-elements)issue is, It's not supporting Base 64 binary data conversion to normal format..

But in salesforce developer guide docs, mentioned that file size limit to upload REST API is 2 GB.
(Copied same lines, links from the articles).

“maximum file size for uploads is 2 GB for ContentVersion objects”,
“To upload a binary file up to 2 GB (including headers) ”,
“Salesforce CRM Content
Content and Libraries tabs in Salesforce Classic
2 GB
2 GB (including headers) when uploaded via Chatter REST API
2 GB (including headers) when uploaded via REST API

https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_sobject_insert_update_blob.htm

https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/intro_input.htm

https://help.salesforce.com/articleView?id=collab_files_size_limits.htm&type=5

Let us know if you worked on the requirement “Upload file to record using REST API (file size should support atleast 100 MB)”

Best Answer

You'll want to read Inputs and Binary File Uploads, but basically, you can't use base-64-encoded data, as far as I can tell. You could try setting Content-Transfer-Encoding to BASE64, but I'm not sure that's supported. That would look like this:

--boundary-code-1234567
Content-Disposition: ...
Content-Type: ...
Content-Transfer-Encoding: BASE64

base64ContentHere===
----boundary-code-1234567

If that doesn't work, then presumably you'll need to use binary instead. Most languages include a way to post literal binary data to a data stream, so it shouldn't be too bad. However, I've never had a need to do this, so you may need to experiment a bit.

I hope this answer helps clarify what's going on.

Related Topic