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

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested answer

How to Store a Large Base64 String in a Custom Table in Business Central?

(2) ShareShare
ReportReport
Posted on by 6

Hi everyone,

I'm working on a custom table in Business Central where I need to store a large Base64 string (coming from a file upload through a custom API). However, the Text data type isn't enough to hold the entire string due to its size limitations.

I’ve tried using the Blob and Media data types as alternatives, but I haven’t been able to get them working correctly for this use case.

Has anyone successfully stored large Base64 strings in a table field? What’s the best practice here? Should I decode the Base64 first and save it in a Blob, or is there a way to store the raw Base64 as text?

Any suggestions or code examples would be much appreciated. Thanks in advance!

I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    91,408 Super User 2025 Season 2 on at
    How to Store a Large Base64 String in a Custom Table in Business Central?
    Hi, hope the following can give you some hitns.
    Dynamics 365 Business Central: How to save a report as encoded text (Base64 String) via AL
    Dynamics 365 Business Central: How to convert Image (item picture) to encoded text (Base64 String) via AL
     
    PS: Dynamics 365 Business Central: Conversion between Blob data type and Media/MediaSet data type
     
    Thanks.
    ZHU
  • Suggested answer
    Sohail Ahmed Profile Picture
    11,013 Super User 2025 Season 2 on at
    How to Store a Large Base64 String in a Custom Table in Business Central?
    the best approach in Business Central to store large Base64 strings is by using a Media or Blob field, and it’s surprising you weren’t able to get it working.
     
    I’d highly recommend using the Media data type in your table. It is designed to handle large binary content such as images, documents, or in your case, large Base64 strings. Rather than saving the raw Base64 string as text (which hits the Text[Max] limits), you should decode the Base64 string and store the binary content using InStream and OutStream.
     
    🔧 Here's a simple example using Media and InStream:
     
    procedure StoreBase64InMedia(Base64Str: Text)
    var
        TempBlob: Codeunit "Temp Blob";
        InS: InStream;
        MediaRef: Media;
    begin
        // Decode base64 to binary and write into a stream
        TempBlob.CreateOutStream(InS);
        Base64.ConvertFromBase64(Base64Str, InS);
     
        // Assign decoded stream to Media field
        TempBlob.CreateInStream(InS);
        Rec.MyMediaField.ImportStream(InS, 'UploadedFile.bin'); // Name can be anything
        Rec.Modify();
    end;
     
    Just make sure your table has a field like this:
     
    field(10; MyMediaField; Media) { }
     
    Let me know if you'd prefer to use a Blob instead — both work well, but Media is more suitable for large unstructured content.
     
    ✅ Mark below checkbox to make this answer Verified if it helps you.
     
     

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Nimsara Jayathilaka. Profile Picture

Nimsara Jayathilaka. 3,406

#2
Sumit Singh Profile Picture

Sumit Singh 2,852

#3
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 2,217

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans