The LEADTOOLS Documents library supports uploading documents from the user drive to the cache system. This support comes handy when the cache is hosted on a separate machine not accessible to the user. For example, when the Documents class is hosted in a web service with a JavaScript or rich client application. Such as the HTML5/JavaScript version of the LEADTOOLS Document Viewer using the LEADTOOLS Documents Web Service.
Uploading a document is supported only a valid instance of LEADTOOLS Cache Object is passed to DocumentFactory.UploadDocument or setup in the global DocumentFactory.Cache property.
All the methods for uploading a document are in the DocumentFactory class. Uploading the document can be done in chunks to show a progress bar and optionally allow the user to abort the application. Following are the steps required to perform this operation:
The application should first prompt the user for the location of the document and then obtain a file stream object with read access to the original file.
Create an instance of UploadDocumentOptions that can be populated with any optional values and then call the BeginUpload method. This method will return a temporary URL object to identity created by the DocumentFactory to identity this document for subsequent calls. This is a custom URL value in the following scheme leadcache://unique_guid_identifier
and is not meant to be used by anything other than the rest of the upload methods. This value must be saved in the application in a local variable at this point.
Read a chunk from the source file into a byte array. The size of this chunk is up to the user, the larger the chunk size, the shorter the whole upload operation but a too large of a chunk might throttle the server connection. A value of 64K is a good minimum. Once the chunk is read, call the DocumentFactory.UploadDocument method passing the URL value obtained from BeginUpload and the chunk of data.
Repeat till all the file is read and uploaded. Then simply call the LoadFromUri method as usual when loading a document from a remote URL, the DocumentFactory class will check the value of the URL and can identity that this is an uploaded document that does not have access to the physical file and instead parses the document from the uploaded data. The data is stored in the cache and is disposed when the Document object is disposed and its cache items are expired.
The upload URL is not needed once the Document object is obtained. The Document object itself and DocumentId are used as usual to interact with the document from this point on.
At any point during uploading the document, DocumentFactory.AbortUploadDocument can be called to abort the operation and DocumentFactory will delete the data uploaded so far from the cache immediately.
For an example, refer to DocumentFactory.BeginUpload.
Loading Using LEADTOOLS Documents Library
Creating Documents with LEADTOOLS Documents Library
Documents Library Coordinate System
Loading Encrypted Files Using the Documents Library
Parsing Text with the Documents Library
Barcode processing with the Documents Library
Products |
Support |
Feedback: Uploading Using the Documents Library |
Introduction |
Help Version 19.0.2017.6.21
|
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.