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
Archana AiyerArchana Aiyer 

Upload files into Onedrive from Salesforce

We are looking at using Onedrive to store very large files/documents. Is there a way using files connect, we can upload files into Onedrive from salesforce?

NagaNaga (Salesforce Developers) 
Hi Archana,

 To upload files to a new folder in OneDrive, first create the folder, and then upload the files to it. Files that are 0 bytes in size can't be uploaded from the OneDrive website.

Please let me know if this helps

Best Regards
Naga kiran
Archana AiyerArchana Aiyer
Hi Naga,
Thank you for the details. But i am looking for a way to upload the files into onedrive from Salesforce. Do you know if there is a way of doing it or should that has to be done through API calls to onedrive?

Eric BowdenEric Bowden
From my experience and reading, Files Connect and External Objects are read-only and thus this must be accomplished using through API calls to SharePoint.

We created a product in the App Exchange called Trove which allows users to upload documents into SharePoint from Salesforce and associate those to Accounts and Opportunities, but as of today, Trove doesn't utilize Files Connect.  

For a solution which utilizes Files Connect, I envision the solution for uploading files would be custom Apex/Visualforce page.  I would use the SharePoint REST API for Files (  You'll want to be sure to use the "chunked" method for uploading files which involves using BeginUpload/ContinueUpload/FinishUpload API methods of the SharePoint REST API so that you don't hit the 6MB heap size limit in Apex code.  Also, you'll need to decide where to store files in SharePoint:  Does the user choose the library and folder on their own or will the custom Apex code choose the library/folder for them.

Authentication into SharePoint Online is a bit of a challenge, but it is made easier by using Auth Providers and Named Credentials that are built into Salesforce.  You can also code your own OAuth flow if you have custom needs.

I imagine I provided more answer than you're after right now but hopefully that was helpful.  Today, I happen to be exploring Files Connect myself.  I'm happy to share more details and experience if it's helpful.
Archana AiyerArchana Aiyer
Thank you Eric.  We are not sure if we are going to use OneDrive as our external Data Storage Solution. If we do then to upload files we will be using the Rest APIs by OneDrive for Files.
Vyankatesh ChoulwarVyankatesh Choulwar


I am in need of solution of this problem.I am facing problem while making authentication in sharepoint.Is there any way to get access token in salesforce from sharepoint?

How do we call sharepoint rest api from salesforce?
Please do needful.

Dhanik L SahniDhanik L Sahni

Refer blog for direct integration with Microsoft one drive using apex.

Thank you,

Michael TomarMichael Tomar
As an alternative for Files Connect, you can try out Skyvia. It has a much simpler UI and allows you to automate data export without coding. Learn more about Onedrive Salesforce integration here: