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.