Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Quentin 2 posts 71 karma points
    Feb 08, 2024 @ 21:47
    Quentin
    0

    Converting a MediaWithCrops file to a byte array inside Umbraco Api Controller

    Hello,

    I am trying to access a media uploaded on the backoffice via an Umbraco API Controller (because I will call the method from my frontend with Ajax). The media is a .xlsx file that I have to convert to a byte array (I think) in order to browse it and return the data I want to the client.

    Here is the start of the method :

     public async Task<IList<ProfessionnelRepertoireViewModel>> GetRepertoireDesProfessionnels()
        {
            var content = _contentQuery.ContentSingleAtXPath("//homePage/espaceAcheteur/repertoireDesProfessionnels");
            var repertoireDesProfessionnels = content.Value<MediaWithCrops<File>>("professionalsDirectory");
    
            return new List<ProfessionnelRepertoireViewModel>();
        }
    

    I successfully retrieved the file (which is repertoireDesProfessionnels) as a MediaWithCrops<File>. Now, I'm really lost on what to do next. I think I tried everything, IMediaService, MediaFileManager and then some but I can't wrap my head around what I should now.

    Thanks for your help!

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies