The static GetBlobRefsForDoc method of the BlobReferenceAPI class will return all of the external BLOB files associated with a given document URL in SharePoint. Since SharePoint can have multiple publishing versions and regular versions associated with a single document URL, this method returns a list of all of the relevant BLOBs
The following is an example of using the BlobReferenceAPI object to retrieve all of the BLOB file references associated with an URL and iterating through the results :
List<BlobReferenceAPI> blobRefs = BlobReferenceAPI.GetBlobRefsForDoc(http://site1/web1/lib/file.docx);
foreach (BlobReferenceAPI blobRef in blobRefs)
{
MessageBox.Show("Blob Found: " + blobRef.DocType.ToString() +
", Size=" + blobRef.BlobSize +
", Version: " + blobRef.Version +
", Publishing Level: " + blobRef.DocLevel.ToString() +
", File Path: " + blobRef.FilePath);
}
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);
}
© 2024 Quest Software Inc. ALL RIGHTS RESERVED. Nutzungsbedingungen Datenschutz Cookie Preference Center