UPLOAD

Used to upload a file into a document library.

Note! For best performance in your application set the connection string option StreamBuffering to false. By default, this option is True because some SharePoint installations do not support pre-authentication. For the complete listing of options see Connection String Options.

 Syntax

UPLOAD(string listName, string file, byte[] data);

Example: to create a simple UTF-8 text file named helloworld.txt under folder Textfiles in document library Shared Documents:

CALL UPLOAD('Shared Documents', 'Textfiles/helloworld.txt', 'This is a small text file...');

Example: to upload binary content, such as a jpg image, simply use:

Upload byte array

using (var connection = new SharePointConnection(connectionString))
{
    connection.Open();
    using (var command = new SharePointCommand(@"CALL UPLOAD('Shared Documents', 'Images/bendsoft.jpg', @doc)", connection))
    {
        command.Parameters.Add("@doc", System.IO.File.ReadAllBytes(@"C:\bendsoft.jpg"));
        command.ExecuteNonQuery();
    }
}

Note! There is no built-in limitation in the Connector for how large files that can be uploaded. By default SharePoint allows a maximum file size of 50MB that can be uploaded into any document library.

To change the maximum file size in SharePoint 2010:

  • Login to SharePoint Central Administration.
  • Navigate to Central Administration -> Application Management -> Manage Web Applications.
  • Select the Web Application you want to change and then click on General Settings.
  • Locate the Maximum Upload Size setting and change the value according to your needs.

Note! Uploading very large files to SharePoint will often require an unwanted amount of memory resources. To overcome this issue, it is recommended to use the streaming approach demonstrated below.

Example: to upload a large file on disk named 150Mb.bin using the streaming method, write:

Upload stream input

using (var connection = new SharePointConnection(connectionString))
{
    connection.Open();
    using (var fs = System.IO.File.OpenRead(@"C:\150Mb.bin"))
    {
        using (var command = new SharePointCommand(@"CALL UPLOAD('Shared Documents', '150Mb.bin', @doc)", connection))
        {
            command.Parameters.Add("@doc", fs);
            command.ExecuteNonQuery();
        }
    }
}

Skip Navigation Links.

Visa     MasterCard