Starts uploading a document to the cache.
public static Uri BeginUpload(
UploadDocumentOptions options
)
Public Shared Function BeginUpload(
ByVal options As UploadDocumentOptions
) As System.Uri
public:
static System::Uri^ BeginUpload(
UploadDocumentOptions^ options
)
public static URI beginUpload(UploadDocumentOptions options)
options
Options to use with the new document. This value cannot be null.
The temporary URL for the uploaded document.
This method will throw an exception if neither UploadDocumentOptions.Cache nor Cache has been set up 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 LEADDocument object from the data.
When uploading is finished, EndUpload must be called to inform the factory that the uploading process has finished.
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 Document Library for detailed information on how to use these methods and the various options available.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Document.Writer;
using Leadtools.Svg;
using LeadtoolsExamples.Common;
using Leadtools.Document;
using Leadtools.Caching;
using Leadtools.Annotations.Engine;
using Leadtools.Ocr;
using Leadtools.Barcode;
using Leadtools.Document.Converter;
public static void DocumentFactoryBeginUploadExample()
{
var cache = GetCache();
// Upload the document in 32K chunks
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))
{
// Start uploading
var uploadOptions = new UploadDocumentOptions();
uploadOptions.Cache = cache;
// Optional: set the mime type of the document we are uploading.
// If this value is not provided or is wrong then it will be overridden by the factory when LoadFromUri is called.
uploadOptions.MimeType = "application/pdf";
// Optional: set the name of the document, the same name as the file.
// This value is only important as a hint when the document file data does not contain a valid signature, such as TXT or XML files
uploadOptions.Name = "Leadtools.pdf";
uploadUri = DocumentFactory.BeginUpload(uploadOptions);
int bytes;
do
{
bytes = reader.Read(buffer, 0, bufferSize);
if (bytes > 0)
{
// Upload a chunk
DocumentFactory.UploadDocument(cache, uploadUri, buffer, 0, bytes);
}
}
while (bytes > 0);
}
// We are done, this method is optional, we can call LoadFromUri right now
DocumentFactory.EndUpload(cache, uploadUri);
// Now load the document
var options = new LoadDocumentOptions();
options.Cache = cache;
using (var document = DocumentFactory.LoadFromUri(uploadUri, options))
{
PrintOutDocumentInfo(document);
}
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Document.Writer
Imports Leadtools.Svg
Imports Leadtools.Document
Imports Leadtools.Caching
Imports Leadtools.Annotations.Engine
Imports Leadtools.Barcode
Imports Leadtools.Ocr
Imports LeadtoolsDocumentExamples.LeadtoolsExamples.Common
Imports Leadtools.Document.Converter
Public Shared Sub DocumentFactoryBeginUploadExample()
Dim cache As ObjectCache = GetCache()
' Upload the document in 32K chunks
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)
' Start uploading
Dim uploadOptions As New UploadDocumentOptions()
uploadOptions.Cache = cache
' Optional: set the mime type of the document we are uploading.
' If this value Is Not provided Or Is wrong then it will be overridden by the factory when LoadFromUri Is called.
uploadOptions.MimeType = "application/pdf"
' Optional: set the name of the document, the same name as the file.
' This value Is only important as a hint when the document file data does Not contain a valid signature, such as TXT Or XML files
uploadOptions.Name = "Leadtools.pdf"
uploadUri = DocumentFactory.BeginUpload(uploadOptions)
Dim bytes As Integer
Do
bytes = reader.Read(buffer, 0, bufferSize)
If bytes > 0 Then
' Upload a chunk
DocumentFactory.UploadDocument(cache, uploadUri, buffer, 0, bytes)
End If
Loop While bytes > 0
End Using
' We are done, this method Is optional, we can call LoadFromUri right now
DocumentFactory.EndUpload(cache, uploadUri)
' Now load the document
Dim options As New LoadDocumentOptions()
options.Cache = cache
Using document As Leadtools.Document.LEADDocument = DocumentFactory.LoadFromUri(uploadUri, options)
PrintOutDocumentInfo(document)
End Using
End Sub
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document