LEADTOOLS Support
General
General Questions
How do I do file cache if I use LoadFromFile in DocumentsService Demo project?
#1
Posted
:
Thursday, November 16, 2017 9:42:37 AM(UTC)
Groups: Registered
Posts: 27
Thanks: 12 times
How do I do file cache if I use LoadFromFile in DocumentsService Demo project? Thanks in advance.
#2
Posted
:
Thursday, November 16, 2017 10:56:27 AM(UTC)
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 methodLoadDocumentOptions classCache propertyAnthony Northrup
Developer Support Engineer
LEAD Technologies, Inc.
1 user thanked Anthony Northrup for this useful post.
#3
Posted
:
Monday, November 20, 2017 9:12:51 AM(UTC)
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)
Groups: Registered, Tech Support, Administrators
Posts: 199
Was thanked: 28 time(s) in 28 post(s)
#5
Posted
:
Monday, November 20, 2017 10:28:10 AM(UTC)
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)
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.
1 user thanked Anthony Northrup for this useful post.
#7
Posted
:
Monday, November 20, 2017 11:40:05 AM(UTC)
Groups: Registered
Posts: 27
Thanks: 12 times
#8
Posted
:
Monday, November 20, 2017 4:38:19 PM(UTC)
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 methodAnthony Northrup
Developer Support Engineer
LEAD Technologies, Inc.
1 user thanked Anthony Northrup for this useful post.
LEADTOOLS Support
General
General Questions
How do I do file cache if I use LoadFromFile in DocumentsService Demo project?
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.