These prerequisites are applicable to only SharePoint 2016 on premise farm. SharePoint online supports large file uploads by default so no need to do any changes in case of SharePoint online. In this blog, we have covered file upload with SharePoint Visual WebPart farm solution. In case of SharePoint online, provider hosted app model can be used. Let's have a look into high level information of the areas used for uploading large file.
Large file handling managed CSOM API's - StartUpload, ContinueUpload, and FinishUpload
For more information about this API and core logic you can refer below link:
These API's are introduced and applicable for SharePoint 2016 and SharePoint Online.
In this approach, large files are broken into the chunks and uploaded to the server. We have to define chunk size considering network bandwidth and standards. In our case, we have defined 2MB of chunk size for uploads. We can resume upload operation if it fails in case of any network disturbances, but for that we have to maintain the state of each and every uploaded chunk. However, retrying of failed chunks functionality has not been covered in this blog.
In order to handle all these chunks we have to write a handler or web service at the server side using managed CSOM file upload API's.
It is very important to select a file upload control that will help us to break the file in chunks and post it to the server for uploading. For this we have used blueimp file upload J-Query control. This is really good control and has lot of features like, progress bar, statistics of file upload operations, sequential and parallel uploads, single file upload, multi file upload, drag and drop, resume uploads, cancel uploads, retry failed chunk operations. Similarly there are lot of helpful features and good documentation on github.
Now, we are going to see in detail each and every operation which are highlighted above. The use case is that we are going to create visual WebPart to upload large files in the SharePoint document library. It supports multi file upload, drag and drop and progress bar indicator. ADFS is configured for authentication.
And also I would suggest to perform large file upload operation in the OOTB document library to make sure everything is in place.
https://nikpatel.net/2012/02/12/enable-asp-net-session-state-on-sharepoint-2010-application/
Core business logic resides into this handler, and it supports multiple file upload functionality.
We have used new SharePoint 2016 API's for file upload into this handler. The logic is to identify first chunk, middle chunk and last chunk to follow StartUpload, ContinueUpload, and FinishUpload execution.
Please note that in this demo we have handled only POST request. GET and DELETE can be added for further improvements and functionality.
How to write handler in SharePoint is not covered in this POC, you can refer below blog to about custom handler in SharePoint.
https://tjendarta.wordpress.com/2014/07/31/create-custom-http-handler-in-sharepoint/
If you have ADFS authentication then, in that case, you need to create client context as per provided guidelines in the below blog
https://mikesmode.wordpress.com/2016/08/14/using-csom-with-saml-authentication-adfs/
Please make sure that the token constants are modified according to your environment.
In case you are not having ADFS configured, then you can use client context creation directly as suggested in below link.
https://msdn.microsoft.com/en-us/library/office/ee537538(v=office.14).aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1
We have used blueimp file upload control for uploading files. For this POC, only few of features have been utilized from this control. This control has lot of features which can be explored by below link,
https://github.com/blueimp/jQuery-File-Upload
You can download source for large file upload POC from below
https://github.com/gaikwaduc/SP2016LargeFileUploaderWebPart