I have a C# application in which, using the SharePoint.Client dll, I make client requests to SharePoint Online. Recently, as per this post, I was able to successfully upload a single 5GB file to SharePoint Online Document Library. However, I am unable to download the same! Here's what I have tried so far:
FileInformation fileInformation = File.OpenBinaryDirect(clientContext, serverRelativeUrl);
The above line of code executes successfully for smaller files. But when I try to download my 5GB file, it throws an IOException: Stream was too long.
File oFile = web.GetFileByServerRelativeUrl(strServerRelativeURL); clientContext.Load(oFile); ClientResult<Stream> stream = oFile.OpenBinaryStream(); clientContext.ExecuteQuery();
There again, for the same set of smaller files, the above code also executes successfully and the files get downloaded easily. But the download of the 5GB file fails immediately at the ExecuteQuery line with a FormatException: Invalid MIME content-length header encountered on read.
Is there a way to download large files from SharePoint Online through code? I can directly download the file from the browser, but not sure how to do the same through code. Plz advice.
EDIT: 1 Here's a reference to a blog which confirms the fact that SharePoint now allows uploading files upto 10 GB each.