More in this section

Forums / General Discussions / Getting document's bytes with fluent

Getting document's bytes with fluent

8 posts, 0 answered
  1. Paolo
    Paolo avatar
    147 posts
    Registered:
    11 Jun 2009
    18 May 2011
    Link to this post
    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
  2. Paolo
    Paolo avatar
    147 posts
    Registered:
    11 Jun 2009
    19 May 2011
    Link to this post
    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?
  3. Paolo
    Paolo avatar
    147 posts
    Registered:
    11 Jun 2009
    23 May 2011
    Link to this post
    no way?
  4. Kristian
    Kristian avatar
    214 posts
    Registered:
    03 Jun 2010
    23 May 2011
    Link to this post
    Telerik.Sitefinity.Libraries.Model.Document.TotalSize

    Will get you the size in bytes
  5. Paolo
    Paolo avatar
    147 posts
    Registered:
    11 Jun 2009
    24 May 2011
    Link to this post
    Hello Kristian,
    I need to get the bytes, not the total size!
    Thanks
  6. Kristian
    Kristian avatar
    214 posts
    Registered:
    03 Jun 2010
    24 May 2011
    Link to this post
    are you refering to the content that is within the document? I'm not sure there is a sitefinity api for that
  7. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    30 Oct 2017
    25 May 2011
    Link to this post
    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
  8. Jonathan
    Jonathan avatar
    8 posts
    Registered:
    19 Apr 2011
    22 Jun 2011
    Link to this post
    Awesome! I've been wasting so much time on this!!!
    Thank you.
8 posts, 0 answered