LEADTOOLS SharePoint Client (Leadtools.SharePoint.Client assembly)

GetDownloadStream Method

Show in webframe
Example 





The full URI for the source item in the SharePoint server. This value cannot be null (Nothing in Visual Basic). It must be the URI to a valid SharePoint item, for example http://server/Shared Documents/File.ext.
Obtains a stream that can be used to download an item from a SharePoint server.
Syntax
public SharePointClientDownloadData GetDownloadStream( 
   Uri sourceUri
)
'Declaration
 
Public Function GetDownloadStream( _
   ByVal sourceUri As Uri _
) As SharePointClientDownloadData
'Usage
 
Dim instance As SharePointClient
Dim sourceUri As Uri
Dim value As SharePointClientDownloadData
 
value = instance.GetDownloadStream(sourceUri)

            

            
public:
SharePointClientDownloadData^ GetDownloadStream( 
   Uri^ sourceUri
) 

Parameters

sourceUri
The full URI for the source item in the SharePoint server. This value cannot be null (Nothing in Visual Basic). It must be the URI to a valid SharePoint item, for example http://server/Shared Documents/File.ext.

Return Value

A SharePointClientDownloadData object that contains the stream data.
Remarks

You can use the SharePointClientDownloadData.Stream property of the returned object to get access to the stream containing the downloaded item data (buffer).

The SharePointClientDownloadData.ETag property will contain the SharePoint ETag that identifies a version of the file. This is obtained directly from SharePoint and is not used by SharePointClient.

In most cases, the stream is an HTTP stream and the Stream.CanSeek value will be set to false. Hence, you should read the data from the stream in a forward direction only and not make any assumption regarding the stream length as shown in the examples.

The SharePointClientDownloadData class implements the System.IDisposable interface. Follow the standard .NET dispose pattern when using the SharePointClientDownloadData class. For more information, refer to the System.IDisposable interface documentation in MSDN.

Note: You should not dispose of the the object in the SharePointClientDownloadData.Stream property yourself, instead, the object will be disposed when you call dispose on the owner SharePointClientDownloadData.

This method will not return until the item is finished downloading. If an error occurs, this method will throw an exception.

To get the download stream asynchronously, use GetDownloadStreamAsync.

To download an item to a disk file, use DownloadFile or DownloadFileAsync.

To upload an item to SharePoint, use UploadFile, UploadFileAsync, UploadStream or UploadStreamAsync.

Example
Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.SharePoint.Client

Private Shared Sub SharePointClientDownloadStreamExample()
   ' Replace SHAREPOINT_SITE_URI with a valid URL to a SharePoint site, for example
   ' http://SiteCollection/MySite
   Dim siteUri As New Uri(SHAREPOINT_SITE_URI)
   ' Replace SHAREPOINT_FOLDER_NAME with a valid folder on the site above, for example
   ' "Documents" or "Documents\Sub Documents"
   Dim folderName As String = SHAREPOINT_FOLDER_NAME

   ' Replace SHAREPOINT_DOCUMENT_NAME with a valid document on the folder above, for example
   ' MyDocument.tif
   Dim documentName As String = SHAREPOINT_DOCUMENT_NAME

   ' Build the full URL to the document are we going to download
   Dim builder As New UriBuilder(siteUri)
   builder.Path = Path.Combine(builder.Path, folderName)
   builder.Path = Path.Combine(builder.Path, documentName)
   Dim sourceDocumentUri As Uri = builder.Uri

   Dim spClient As New SharePointClient()

   ' Optional: Set the credentials:
   spClient.Credentials = New NetworkCredential(USER_NAME, PASSWORD, DOMAIN)

   ' Get the stream to the SharePoint item
   Using data As SharePointClientDownloadData = spClient.GetDownloadStream(sourceDocumentUri)
      ' Use RasterCodecs to get its information
      Using codecs As New RasterCodecs()
         Using imageInfo As CodecsImageInfo = codecs.GetInformation(data.Stream, True)
            ' Show the image info
            Console.WriteLine("URL:        {0}", sourceDocumentUri)
            Console.WriteLine("Pages:      {0}", imageInfo.TotalPages)
            Console.WriteLine("Size:       {0} by {1} pixels", imageInfo.Width, imageInfo.Height)
            Console.WriteLine("Resolution: {0} by {1} dpi", imageInfo.XResolution, imageInfo.YResolution)
            Console.WriteLine("Bits/Pixel: {0}", imageInfo.BitsPerPixel)
         End Using
      End Using
   End Using
End Sub
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;
using Leadtools.SharePoint.Client;

private static void SharePointClientDownloadStreamExample()
{
   // Replace SHAREPOINT_SITE_URI with a valid URL to a SharePoint site, for example
   // http://SiteCollection/MySite
   Uri siteUri = new Uri(SHAREPOINT_SITE_URI);
   // Replace SHAREPOINT_FOLDER_NAME with a valid folder on the site above, for example
   // "Documents" or "Documents\Sub Documents"
   string folderName = SHAREPOINT_FOLDER_NAME;

   // Replace SHAREPOINT_DOCUMENT_NAME with a valid document on the folder above, for example
   // MyDocument.tif
   string documentName = SHAREPOINT_DOCUMENT_NAME;

   // Build the full URL to the document are we going to download
   UriBuilder builder = new UriBuilder(siteUri);
   builder.Path = Path.Combine(builder.Path, folderName);
   builder.Path = Path.Combine(builder.Path, documentName);
   Uri sourceDocumentUri = builder.Uri;

   SharePointClient spClient = new SharePointClient();

   // Optional: Set the credentials:
   spClient.Credentials = new NetworkCredential(USER_NAME, PASSWORD, DOMAIN);

   // Get the stream to the SharePoint item
   using (SharePointClientDownloadData data = spClient.GetDownloadStream(sourceDocumentUri))
   {
      // Use RasterCodecs to get its information
      using (RasterCodecs codecs = new RasterCodecs())
      {
         using (CodecsImageInfo imageInfo = codecs.GetInformation(data.Stream, true))
         {
            // Show the image info
            Console.WriteLine("URL:        {0}", sourceDocumentUri);
            Console.WriteLine("Pages:      {0}", imageInfo.TotalPages);
            Console.WriteLine("Size:       {0} by {1} pixels", imageInfo.Width, imageInfo.Height);
            Console.WriteLine("Resolution: {0} by {1} dpi", imageInfo.XResolution, imageInfo.YResolution);
            Console.WriteLine("Bits/Pixel: {0}", imageInfo.BitsPerPixel);
         }
      }
   }
}
Requirements

Target Platforms

See Also

Reference

SharePointClient Class
SharePointClient Members

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.