Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Thursday, November 16, 2017 9:42:37 AM(UTC)

Jay911  
Jay911

Groups: Registered
Posts: 27

Thanks: 12 times

How do I do file cache if I use LoadFromFile in DocumentsService Demo project? Thanks in advance.
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Thursday, November 16, 2017 10:56:27 AM(UTC)
Anthony Northrup

Groups: Registered, Tech Support, Administrators
Posts: 199

Was thanked: 28 time(s) in 28 post(s)

Hello Jay,

I'm not quite sure what you are asking, but if you want to load from a file using the cache, simply supply the Cache property to the LoadDocumentOptions object you pass to the LoadFromFile method. Here are the documentation links:
LoadFromFile method
LoadDocumentOptions class
Cache property
Anthony Northrup
Developer Support Engineer
LEAD Technologies, Inc.

LEAD Logo
thanks 1 user thanked Anthony Northrup for this useful post.
Jay911 on 11/20/2017(UTC)
 
#3 Posted : Monday, November 20, 2017 9:12:51 AM(UTC)

Jay911  
Jay911

Groups: Registered
Posts: 27

Thanks: 12 times

Hi Anthony,

How do I get document as blob from the document cache? I want to get document from the cache, convert it to blob and save it to database.

public SaveToCacheResponse SaveToCache(SaveToCacheRequest request)
{

if (request == null)
{
throw new ArgumentNullException("request");
}
if (request.Descriptor == null)
{
throw new ArgumentNullException("Descriptor");
}
var jsonSerialiser = new JavaScriptSerializer();
var userData = jsonSerialiser.Deserialize<dynamic>(request.UserData.ToString());
var serverPath = HttpUtility.UrlDecode(userData["url"]);
//pages,rotateDegrees
var pages = userData["pages"].Split(',');
var rotateDegrees = userData["rotateDegrees"].Split(',');

var cache = ServiceHelper.Cache;

// First try to load it from the cache, if success, update it. Otherwise, assume it is not there and create a new document

using (var document = DocumentFactory.LoadFromCache(cache, request.Descriptor.DocumentId))
{
if (document != null)
{

// Update it
document.UpdateFromDocumentDescriptor(request.Descriptor);
document.AutoDeleteFromCache = false;
document.AutoDisposeDocuments = true;
document.AutoSaveToCache = false;
document.SaveToCache();
return new SaveToCacheResponse { Document = document };
}
}

// Above failed, create a new one.
var createOptions = new CreateDocumentOptions();
createOptions.Descriptor = request.Descriptor;
createOptions.Cache = cache;
createOptions.UseCache = cache != null;
createOptions.CachePolicy = ServiceHelper.CreatePolicy();
using (var document = DocumentFactory.Create(createOptions))
{
if (document == null)
throw new InvalidOperationException("Failed to create document");

CacheController.TrySetCacheUri(document);
document.AutoDeleteFromCache = false;
document.AutoDisposeDocuments = true;
document.AutoSaveToCache = false;
document.SaveToCache();
return new SaveToCacheResponse { Document = document };

}
}
 
#4 Posted : Monday, November 20, 2017 9:42:42 AM(UTC)
Anthony Northrup

Groups: Registered, Tech Support, Administrators
Posts: 199

Was thanked: 28 time(s) in 28 post(s)

Hello Jay,

We have a guide of how to implement an Azure Redis Cache with Storage Blobs here: https://www.leadtools.com/help/leadtools/v19/dh/to/dox-topics-azurerediscachewithstorageblobsexample.html
In the code on that page is the function GetFromCacheAndBlobStorage which can return the document as a blob, though since it's a private function you will need to access it via the GetCacheItem method.
Anthony Northrup
Developer Support Engineer
LEAD Technologies, Inc.

LEAD Logo
 
#5 Posted : Monday, November 20, 2017 10:28:10 AM(UTC)

Jay911  
Jay911

Groups: Registered
Posts: 27

Thanks: 12 times

Thanks for the reply.

I am not using Azure. I am just trying to get file (e.g exmple.tif) out of cache, so I can post it to a web service which will save it to database.
 
#6 Posted : Monday, November 20, 2017 11:24:33 AM(UTC)
Anthony Northrup

Groups: Registered, Tech Support, Administrators
Posts: 199

Was thanked: 28 time(s) in 28 post(s)

Hello Jay,

We currently don't have a way to store a Document to stream in order to convert to a blob. We have a feature request for this open, but at this time there isn't any way to do this.
Anthony Northrup
Developer Support Engineer
LEAD Technologies, Inc.

LEAD Logo
thanks 1 user thanked Anthony Northrup for this useful post.
Jay911 on 11/20/2017(UTC)
 
#7 Posted : Monday, November 20, 2017 11:40:05 AM(UTC)

Jay911  
Jay911

Groups: Registered
Posts: 27

Thanks: 12 times

Thanks Anthony.

Is there any example for SaveToUri method. How do I set up webclient on server end to accept data from DocumentService SaveToUri
https://www.leadtools.co.../document-savetouri.html
 
#8 Posted : Monday, November 20, 2017 4:38:19 PM(UTC)
Anthony Northrup

Groups: Registered, Tech Support, Administrators
Posts: 199

Was thanked: 28 time(s) in 28 post(s)

Hello Jay,

After a lot of testing I discussed this issue with a colleague of mine, they said the only way to get the byte data of a document is:

You can get a temporary file with the GetTemporaryFileName method
Anthony Northrup
Developer Support Engineer
LEAD Technologies, Inc.

LEAD Logo
thanks 1 user thanked Anthony Northrup for this useful post.
Jay911 on 11/20/2017(UTC)
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.120 seconds.