web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Business Central forum

How to Convert Instream Value to Base64String

(0) ShareShare
ReportReport
Posted on by 449

Hi Everyone,

Need to convert  Instream Value to Base64String in AL Code(Extension in Visual Studio Code).

When i write a function for conversion, it takes almost an hour to covert in Base64String.

There is a "TempBlob" Table with function "Base64String" but i am unable to go through it, as it requires a blob field also.

Please Suggest. 

Categories:
  • Verified answer
    Community Member Profile Picture
    on at

    Hi Manish,

    You should use blob data type and a TempBlob if you wanna use its toBase64String function.

    Try this code

        var
            vConvertedContent: text;
            varTempBlob: Record TempBlob Temporary;
            varInStream: InStream;
            varOutStream: OutStream;
        begin
            ......................................
            ......................................
            varTempBlob.Init();
            varTempBlob.insert();
            varTempBlob.Blob.CreateOutStream(varOutStream, TextEncoding::UTF8);
            CopyStream(varOutStream, varInStream);
            vConvertedContent := varTempBlob.ToBase64String();


    First of all, you should fill your blob field (field of TempBlob) by your Instream in order to use the ToBase64String function. To do this, you should pass by an Outstream that's why we copy the InStream to OutStream via the CopyStream function.

    The function toBase64String here converts the blob field (which is your InStream) to base64 and returns the result as text (vConvertedContent).

    Don't hesitate if If you need more details or explanations.

    -------------

    Please verify my answer if you find my answer helpful. Doing so you'll show other community members that there was found a solution and you credit my help.

    -------------

    Best Regards,

  • Manish Ratan Profile Picture
    449 on at

    G8 :) ... it worked.

    Thanks!!!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans