The Large File Upload API exposes the ability to upload a large file, similar to the Large File Upload interface on the SharePoint document library ribbon. Only one file at a time can be uploaded with this method. Large File Support must be enabled on the SharePoint farm, on StoragePoint General Settings. An active Storage Profile must exist that covers the destination of the uploaded file.
This API must be called on a server in the SharePoint farm and the user running the code must have administrative rights in SharePoint.
Method Reference
The following method is provided by the UploadLargeFileAPI object:
Method Name |
Parameters |
Description |
void PerformUploadLargeFile(string fullFilename, string listUrl) |
ListURL - Destination URL of the Document Library where the file will be uploaded. An example is: http://server/sites/web1/Pages/default.aspx
FullFileName - Full UNC path of the file to be uploaded |
Uploads a file larger than the Web Application upload limit to a document library and externalizes that large file to the profile endpoint. An aspx file is placed in the document library that points to the large file. |
Property Reference
The UploadLargeFileAPI object has properties that can be set to track the upload and log the progress.
Property Name |
Data Type |
Required |
Description |
WrapLogger |
log |
No |
Can be used to set up logging of the large file upload. void SetLoggers(Action<string> Info, Action<string> Error) |
Action |
TrackProgress |
No |
Delegate that could be used for tracking the upload progress, the delegate receive two parameters: bytes already uploaded, and total bytes to be uploaded.
Action<long, long> |
The LargeFileUploaderAPI allows a way to upload large files (those greater than the max upload limit for the Web Application) into a SharePoint Document Library, where a StoragePoint profile is configured.
Basic example, without logs and tracking set:
static void Main(string[] args)
{
var listUrl = "http://server:6003/Shared%20Documents";
var fullFilename = @"c:\Uploads\smFile10M.txt";
LargeFileUploaderAPI uploader = new LargeFileUploaderAPI();
uploader.PerformUploadLargeFile(fullFilename, listUrl);
}
Example with logs set:
static void Main(string[] args)
{
LargeFileUploaderAPI uploader = new LargeFileUploaderAPI();
uploader.log.SetLoggers(Console.WriteLine, Console.WriteLine);
var file = @"C: \documents\windows-8-start-screen. png";
uploader.PerformUploadLargeFile(file, listuri);
}
Example with logs and tracking usage:
static void Main(string[] args)
{
var listUrl = "http://server:6003/Shared%20Documents";
var fullFilename = @"c:\Uploads\smFile10M.txt";
LargeFileUploaderAPI uploader = new LargeFileUploaderAPI();
uploader.log.SetLoggers(Console.WriteLine, Console.WriteLine);
uploader.TrackProgress = (long bytesSent, long total) =>
{
var percentage = total > 0 ? ((float)bytesSent / (float)total) * 100 : 0;
Console.WriteLine("{0} -- {1} : {2}%", bytesSent, total, percentage);
};
uploader.PerformUploadLargeFile(fullFilename, listUrl);
}
The ValidatorAPI object can be used to verify the identities of endpoints and profiles is correct, before executing commands using that information.
Method Name |
Parameters |
Description |
EndpointIdentityValidator (string NameOrID) |
NameORID - The endpoint name or ID to be validated. |
Verifies that the name or ID is valid. |
ProfileIdentityValidator (string profileNameOrID |
NameORID - The profile name or ID to be validated. |
Verifies that the name or ID is valid. |
© ALL RIGHTS RESERVED. Terms of Use Privacy Cookie Preference Center