1
votes

I am trying to upload from code large files (larger then 256MB) in ranges 500 MB - 2GB to sharepoint server 2013 but didn't found a way to do that. I succeded to upload large files with size ~1GB manually.

I have tried the following MSDN examples , it works only for files< 256 MB.

According to this post (at the buttom): "...chunk upload are available only in SharePoint Online and SharePoint 2016 OnPremise and are not available in SharePoint 2013 OnPremise".

My question is how to upload large files to sharepoint server 2013?

1

1 Answers

0
votes

Could use SaveBinaryDirect option to upload large files in SharePoint 2013 Server:

public void SaveBinaryDirect(ClientContext ctx, string libraryName, string filePath)
{
    Web web = ctx.Web;
    // Ensure that target library exists, create if is missing
    if (!LibraryExists(ctx, web, libraryName))
    {
        CreateLibrary(ctx, web, libraryName);
    }

    List docs = ctx.Web.Lists.GetByTitle(libraryName);
    ctx.Load(docs, l => l.RootFolder);
    // Get the information about the folder that will hold the file
    ctx.Load(docs.RootFolder, f => f.ServerRelativeUrl);
    ctx.ExecuteQuery();

    using (FileStream fs = new FileStream(filePath, FileMode.Open))
    {
        Microsoft.SharePoint.Client.File.SaveBinaryDirect(ctx, string.Format("{0}/{1}", docs.RootFolder.ServerRelativeUrl, System.IO.Path.GetFileName(filePath)), fs, true);
    }
}

enter image description here

Reference:

Large file upload with CSOM