Start uploading a document to the cache.
public static System.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 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.
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;
public static void DocumentFactoryBeginUploadExample()
{
var cache = GetCache();
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();
uploadOptions.Cache = cache;
uploadUri = DocumentFactory.BeginUpload(uploadOptions);
int bytes;
do
{
bytes = reader.Read(buffer, 0, bufferSize);
if (bytes > 0)
{
DocumentFactory.UploadDocument(cache, uploadUri, buffer, 0, bytes);
}
}
while (bytes > 0);
}
var options = new LoadDocumentOptions();
options.Cache = cache;
using (var document = DocumentFactory.LoadFromUri(uploadUri, options))
{
PrintOutDocumentInfo(document);
}
}
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 Shared Sub DocumentFactoryBeginUploadExample()
Dim cache As ObjectCache = GetCache()
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()
uploadOptions.Cache = cache
uploadUri = DocumentFactory.BeginUpload(uploadOptions)
Dim bytes As Integer
Do
bytes = reader.Read(buffer, 0, bufferSize)
If bytes > 0 Then
DocumentFactory.UploadDocument(cache, uploadUri, buffer, 0, bytes)
End If
Loop While bytes > 0
End Using
Dim options As New LoadDocumentOptions()
options.Cache = cache
Using document As Leadtools.Documents.Document = DocumentFactory.LoadFromUri(uploadUri, options)
PrintOutDocumentInfo(document)
End Using
End Sub
Products |
Support |
Feedback: BeginUpload Method (DocumentFactory) - Leadtools.Documents |
Introduction |
Help Version 19.0.2017.3.22
|
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.