Skip to main content
Business Central forum
Suggested answer

Downloading file from Blob Field

editSubscribe (2) ShareShare
ReportReport
Posted on by 8
I created custom table with blob field called 'certification' and card for this table. And actions for download/uploading. Both action works without any error but after downloading .pdf file, it does not open and shows error: /Failed to load PDF document./. But it worked fine with 3kb file. Is there size limit for blob field? Or should I use different approach for uploading file to my custom table?

Code for download/upload
procedure UploadFile(DocumentInStream: InStream; FileName: Text)
    var
        OStream: OutStream;
    begin
        Rec.certification.CreateOutStream(OStream);
        CopyStream(OStream, DocumentInStream);
        Modify(true);
    end;
 
    procedure DownloadFile()
    var
        IStream: InStream;
        ExportFileName: Text;
    begin
        ExportFileName := Rec.companyName + ' - ' + Format(Rec.SystemCreatedAt) + '.pdf';
        Rec.CalcFields(Rec.certification);
        If Rec.certification.HasValue then begin
            Rec.certification.CreateInStream(IStream);
            DownloadFromStream(IStream, 'Download', '', '', ExportFileName);
        end;
    end;
Categories:
Attachments
  • Shivi1307 Profile Picture
    Shivi1307 17 on at
  • Suggested answer
    gdrenteria Profile Picture
    gdrenteria 2,812 Super User on at

Helpful resources

Quick Links

New Blog Features Released!

Check out the new community blog features for viewers and authors…

Setting Up Knowledge Sources for Copilot…

Look at how configuring a comprehensive knowledge base is crucial…

Demystifying Copilot with Georg Glantschnig…

Industry experts answer burning questions directly from our amazing Community…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,176 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 222,727 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,138

Featured topics

Product updates

Dynamics 365 release plans