The following table lists the file upload methods that are available and describes when to use each method.
Options for uploading files
File upload option | Considerations | When should you use this? | Supported platforms |
---|---|---|---|
Content property on the FileCreationInformation class. | Maximum file size that can be uploaded is 2 MB. Time-out occurs after 30 minutes. | Use to upload files that are less than 2 MB only. | SharePoint Server, SharePoint Online |
SaveBinaryDirect method on the File class. | No file size limits. Time-out occurs after 30 minutes. | Only use this method if you’re using a user-only authentication policy. A user-only authentication policy is not available in a SharePoint Add-in, but can be used in native device add-ins, Windows PowerShell, and Windows console applications. | SharePoint Server, SharePoint Online |
ContentStream property on the FileCreationInformationclass. | No file size limits. Time-out occurs after 30 minutes. | Recommended for: – SharePoint Server – SharePoint Online when the file is smaller than 10 MB. |
SharePoint Server, SharePoint Online |
Upload a single file as a set of chunks using the StartUpload, ContinueUpload, and FinishUpload methods on the File class. | No file size limits. Time-out occurs after 30 minutes. Each chunk of the file must upload within 30 minutes of completion of the previous chunk to avoid the time-out. | Recommended for SharePoint Online when the file is larger than 10 MB. | SharePoint Online |
Reference:
https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/upload-large-files-sample-app-for-sharepoint