Getting document's bytes with fluent

Posted by Community Admin on 03-Aug-2018 16:10

Getting document's bytes with fluent

All Replies

Posted by Community Admin on 18-May-2011 00:00

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

Posted by Community Admin on 19-May-2011 00:00

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;

I've seen that under ContentItem I got a .Serialize() method that returns an object... can't I use it here?

Posted by Community Admin on 23-May-2011 00:00

no way?

Posted by Community Admin on 23-May-2011 00:00

Telerik.Sitefinity.Libraries.Model.Document.TotalSize

Will get you the size in bytes

Posted by Community Admin on 24-May-2011 00:00

Hello Kristian,
I need to get the bytes, not the total size!
Thanks

Posted by Community Admin on 24-May-2011 00:00

are you refering to the content that is within the document? I'm not sure there is a sitefinity api for that

Posted by Community Admin on 25-May-2011 00:00

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);




All the best,
Boyan Barnev
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 22-Jun-2011 00:00

Awesome! I've been wasting so much time on this!!!
Thank you.

This thread is closed