Error processing SSI file
LEADTOOLS Leadtools.Documents (Leadtools.Documents assembly)

Show in webframe

BeginUpload Method






Options to use with the new document. This value cannot be null.
Start uploading a document to the cache.
Syntax
public static Uri BeginUpload( 
   UploadDocumentOptions options
)
'Declaration
 
Public Shared Function BeginUpload( _
   ByVal options As UploadDocumentOptions _
) As Uri
'Usage
 
Dim options As UploadDocumentOptions
Dim value As Uri
 
value = DocumentFactory.BeginUpload(options)
public static URI beginUpload(UploadDocumentOptions options)
            
public:
static Uri^ BeginUpload( 
   UploadDocumentOptions^ options
) 

Parameters

options
Options to use with the new document. This value cannot be null.

Return Value

The temporary URL for the uploaded document.
Remarks

This method will throw an exception if neither LoadDocumentOptions.Cache nor Cache was setup with a valid cache object.

BeginUpload, UploadDocument and AbortUploadDocument can be used to upload a document in chunks to the cache used by this DocumentFactory. After the document is uploaded, you can use LoadFromUri to create a Document object from the data.

This method returns a URL with a special LEAD cache scheme to indicate a loaded document. This URL can be detected using IsUploadDocumentUri helper method.

Refer to Uploading Using the Documents Library for detailed information on how to use these methods and the various options used.

Example
Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Forms.DocumentWriters
Imports Leadtools.Svg
Imports Leadtools.Documents
Imports Leadtools.Caching
Imports Leadtools.Annotations.Core
Imports Leadtools.Barcode
Imports Leadtools.Forms.Ocr

<TestMethod()> _
Public Sub DocumentFactoryBeginUploadExample()
   Dim cache As FileCache = CreateCache()
   DocumentFactory.Cache = cache
   Const bufferSize As Integer = 1024 * 32
   Dim buffer() As Byte = New Byte(bufferSize - 1) {}

   Dim fileName As String = Path.Combine(ImagesPath.Path, "Leadtools.pdf")
   Dim uploadUri As Uri = Nothing
   Using reader As FileStream = File.OpenRead(fileName)
      Dim uploadOptions As New UploadDocumentOptions()
      uploadUri = DocumentFactory.BeginUpload(uploadOptions)

      Dim bytes As Integer
      Do
         bytes = reader.Read(buffer, 0, bufferSize)
         If bytes > 0 Then
            DocumentFactory.UploadDocument(uploadUri, buffer, 0, bytes)
         End If
      Loop While bytes > 0
   End Using

   Dim options As New LoadDocumentOptions()

   Using document As Leadtools.Documents.Document = DocumentFactory.LoadFromUri(uploadUri, options)
      PrintOutDocumentInfo(document)
   End Using
End Sub
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Forms.DocumentWriters;
using Leadtools.Svg;
using Leadtools.Documents;
using Leadtools.Caching;
using Leadtools.Annotations.Core;
using Leadtools.Forms.Ocr;
using Leadtools.Barcode;

[TestMethod]
public void DocumentFactoryBeginUploadExample()   
{
   var cache = CreateCache();
   DocumentFactory.Cache = cache;
   const int bufferSize = 1024 * 32;
   var buffer = new byte[bufferSize];

   var fileName = Path.Combine(ImagesPath.Path, "Leadtools.pdf");
   Uri uploadUri = null;
   using (var reader = File.OpenRead(fileName))
   {
      var uploadOptions = new UploadDocumentOptions();
      uploadUri = DocumentFactory.BeginUpload(uploadOptions);

      int bytes;
      do
      {
         bytes = reader.Read(buffer, 0, bufferSize);
         if (bytes > 0)
         {
            DocumentFactory.UploadDocument(uploadUri, buffer, 0, bytes);
         }
      }
      while (bytes > 0);
   }

   var options = new LoadDocumentOptions();

   using (var document = DocumentFactory.LoadFromUri(uploadUri, options))
   {
      PrintOutDocumentInfo(document);
   }
}
Requirements

Target Platforms

See Also

Reference

DocumentFactory Class
DocumentFactory Members

Error processing SSI file
   Leadtools.Documents requires a Document or Medical toolkit license and unlock key. For more information, refer to: LEADTOOLS Toolkit Features