Convert Base64 string to insert to media/mediaset datatype in BC17

Hi,

Hope somebody able to help me on this one. Is there a way to convert base64 string and keep the image in media/mediaset datatype field ?

Hey Lie Yan,

Codeunit 4110 has some functions implemented, which holds capabilities of converting to and from Base64. Perhaps you can use them to achieve what you are trying to do.

Here, you’ll find more information github.com/microsoft/ALAppExtensions/

Best

Rob

Thanks. a bit question.

I’m writing this procedure to convert base64 and input the picture in tenant media. but it seems when i execute, it only create tenant media record for the picture but the item didn’t insert the picture. any idea why ?

procedure UploadSignatureBase64(parItemNo: Code[20]; parBase64: Text) returnval: Boolean
var
Item: Record item;
B64cu: Codeunit “Base64 Convert”;
TM: Record “Tenant Media”;
Outstr: OutStream;
begin
//insert tenant media tempblob table and decode base64 to outstream
TM.Init();
TM.ID := CreateGuid();
TM.Description := StrSubstNo(‘Signature%1’, format(CurrentDateTime));
TM.“Mime Type” := ‘image/jpeg’;
TM.“Company Name” := COMPANYNAME;
TM.“File Name” := TM.Description + ‘.jpg’;
TM.Height := 250;
TM.Width := 250;
TM.CalcFields(Content);
TM.Content.CreateOutStream(Outstr);
B64cu.FromBase64(parBase64, Outstr);
TM.Insert;
//insert picture on table with newly made tenant media record
item.get(parItemNo);
clear(item.Picture);
item.picture.insert(TM.ID);
MESSAGE(FORMAT(TM.ID));
exit(true);
end;