Getting document's bytes with fluent
Hello,
how can I get the bytes of a PDF when using fluent api?
I need to search inside it...and I've just the logic to do so
Hello,
so far I've reached
var documents = App.WorkWith().Documents().Where(o1 => o1.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live);
var pdfDocs = documents.Where(o1 => o1.Extension == ".pdf");
foreach (var doc in pdfDocs.Get())
var a = App.WorkWith().Documents().GetManager().GetItem(typeof(Telerik.Sitefinity.Libraries.Model.Document), doc.Id);
Telerik.Sitefinity.Libraries.Model.IChunkContent document = a as Telerik.Sitefinity.Libraries.Model.IChunkContent;
no way?
Telerik.Sitefinity.Libraries.Model.Document.TotalSize
Hello Kristian,
I need to get the bytes, not the total size!
Thanks
are you refering to the content that is within the document? I'm not sure there is a sitefinity api for that
Hello Paolo and Kristian,
As far as I get it, your purpose is not to work with the document as an object but to access its binary content and read that stream. Since you mentioned you have already implemented some logic on how to process that stream, you can get the desired Document as a object with the API and then pass it to the Dwonload() method of LibrariesManager which will return the document from the DB as a stream. Please try the below sample code and let me know if it suits your purposes:
var doc = App.WorkWith().Documents().Where(d => d.Status == ContentLifecycleStatus.Live && d.Title==
"sampleTitle"
).Get().First();
var m = LibrariesManager.GetManager();
var docStream = m.Download(doc);
Awesome! I've been wasting so much time on this!!!
Thank you.