function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RohiniHRohiniH 

What is the best method to receive 5- 10 files of 5 MB each from an External System

Hello,
What is the best method to receive 5- 10 files of 5 MB each from an External System. These file will be attched to Opportunity record, which is already existing in the Salesforce system.
The external system will not send more than 50 Opportunities per day.

Following is the limitation from Salesforce
Maximum size of callout request or response (HTTP request or Web services call) in SFDC is 6 MB for synchronous Apex or 12 MB for asynchronous Apex ,

or
Should the external system use our OOTB REST API 
/services/data/v48.0/sobjects/Opportunity/<ID>
For Attachment
/services/data/v48.0/sobjects/Attachment/<ID>
For Files
/services/data/v48.0/sobjects/ContentVersion/<ID>

We are using files, so ContentVersion looks very close to it, than Attachment

What would be best way without encountering any limitation. 

Kind Regards,
Rohini H
{tushar-sharma}{tushar-sharma}
Hi Rohini,

If external system can use our API then I suggest go with that. As in Salesforce we have limits(You have already mentioned) which might give us trouble if in future we want to increase the size. So to avoid that issue its best if we use standard APIs.

If this answer helps you, please mark it as accepted.

Regards,
Tushar Sharma
https://newstechnologystuff.com/
RohiniHRohiniH
Thanks, Tushar.
It works fine for Composite Request REST API when transferring files with parent record, but using non-multipart, it has a limitation of 37.5 MB of base64–encoded data, so, was trying the option to create/update a file using multipart as mentioned in 'Inserting a ContentVersion'  in https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_sobject_insert_update_blob.htm  link .

But, on executing the command in workbench, PDF files gets uploaded in Salesforce, but I cannot view it. It always says 'Failed to load PDF document.'
Say, to insert a new version of the file using workbench
/services/data/v48.0/sobjects/ContentVersion 
I set the following in the Request Header section 
Content-Type: multipart/form-data; boundary="boundary_string"
Accept: application/json
=====
In Request Body
--boundary_string
Content-Disposition: form-data; name="entity_content";
Content-Type: application/json
{
"ContentDocumentId" : "069D00000000so2",
"ReasonForChange" : "Marketing materials updated",
"PathOnClient" : "Q1 Sales Brochure.pdf"
}
--boundary_string
Content-Type: application/octet-stream
Content-Disposition: form-data; name="VersionData"; filename="Q1 Sales Brochure.pdf"
Binary data goes here.
--boundary_string--

What am I missing to get that message in Workbench for PDF or xls file.
For text file, I had to include 'Content-Transfer-Encoding: base64;' before typing in binary data, else the complete encoded string was visible when viewing the file in Salesforce.

Kind Regards,
Rohini