Al: DownloadFromStream with multiple files in Web Client

Created on 5 Sep 2018  路  13Comments  路  Source: microsoft/AL

If is use the "File Management".BLOBExport function in my Extension i can not download multiple files in the same process if i am using the web client. If use the Windows Client then there is a dialog for all files not only the last one. In the debugger he runs DownLoadFromStream for all files but in the end only the last file is downloaded.
Is there a fix for that?

Code Example:
repeat
FileManagement.BLOBExport(TempBlob,RequestedFilename,true);
until TempBlob.Next() = 0;

cross-team-investigate

Most helpful comment

I had the same problem I "solved" by archiving the files I wanted into a zip archive. If it can help:

    local procedure MyProcedure()
    var
        ZipedFile: OutStream;
        FileName: array[4] of Text;
        FileContent: array[4] of BigText;
        ZipName: Text;
        FileMgt: Codeunit "File Management";
        FileBlob: Record TempBlob temporary;
        ZipBlob: Record TempBlob temporary;
        FileStream: InStream;
        ZipStream: InStream;
        i: Integer;
        FillFiles: Report "Fill Files";
    begin
        FileBlob.Blob.CreateInStream(FileStream);
        ZipBlob.Blob.CreateOutStream(ZipedFile);
        ZipName := StrSubstNo('%1.zip', "Archive Name");

        FillFiles.RunModal();

        FillFiles.GetFileContent(FileName, FileContent);

         for i := 1 to ArrayLen(FileContent) do begin
            FileBlob.WriteAsText(Format(FileContent[i]), TextEncoding::UTF8);
            FileMgt.AddStreamToZipStream(ZipedFile, FileStream, FileName[i]);
         end;
         ZipBlob.Blob.CreateInStream(ZipStream);
         DownloadFromStream(ZipStream, 'Dialog', 'Folder', '', ZipName);
    end;

All 13 comments

Is this question related to NAv 2018?

Dynamics 365 Business Central
Microsoft_Application_12.3.23828.0.app
Microsoft_System_12.0.12928.0.app

AL Compiler: 0.16.19969

I had the same problem I "solved" by archiving the files I wanted into a zip archive. If it can help:

    local procedure MyProcedure()
    var
        ZipedFile: OutStream;
        FileName: array[4] of Text;
        FileContent: array[4] of BigText;
        ZipName: Text;
        FileMgt: Codeunit "File Management";
        FileBlob: Record TempBlob temporary;
        ZipBlob: Record TempBlob temporary;
        FileStream: InStream;
        ZipStream: InStream;
        i: Integer;
        FillFiles: Report "Fill Files";
    begin
        FileBlob.Blob.CreateInStream(FileStream);
        ZipBlob.Blob.CreateOutStream(ZipedFile);
        ZipName := StrSubstNo('%1.zip', "Archive Name");

        FillFiles.RunModal();

        FillFiles.GetFileContent(FileName, FileContent);

         for i := 1 to ArrayLen(FileContent) do begin
            FileBlob.WriteAsText(Format(FileContent[i]), TextEncoding::UTF8);
            FileMgt.AddStreamToZipStream(ZipedFile, FileStream, FileName[i]);
         end;
         ZipBlob.Blob.CreateInStream(ZipStream);
         DownloadFromStream(ZipStream, 'Dialog', 'Folder', '', ZipName);
    end;

@kalberes Do you have any further input for us?
The hint with the zip file is working but only as workaround for a short time. Our customers do not want to unzip the files after D365BC created them.

Unfortunately this scenario is not supported now. We will be looking into implementing multi file download in the web client, but we don鈥檛 have any timeline to share at this point.

This has been added to the client team backlog.

by ar

Hi Can you please explain about FillFiles: Report "Fill Files";
is it customized if yes then can you please put it here
Thanks

Hi,

It's just a report that fills Text and BigText variables (globals). I then use GetFileContent that returns these global variable. It's not necessary and not related to this issue but I let these calls to be more understandable: that's where my file content and file name comes from. You can delete this + the for-loop and hard-code a filename and a filecontent into Text variable to see it work..!

Any updates on this issue? It still seems not to be working.
ES Business Central SaaS 16.0 (Platform 16.0.11233.12436 + Application 16.0.11240.11946)

I also find in this version ES Business Central SaaS 16.0 (Platform 16.0.11233.12436 + Application 16.0.11240.11946) that codeunit File Management does not support method
FileMgt.AddStreamToZipStream
and that codeunit 706 ZIP Stream Wrapper does not exist!
How can we manage ZIP files from Cloud?

I also find in this version ES Business Central SaaS 16.0 (Platform 16.0.11233.12436 + Application 16.0.11240.11946) that codeunit File Management does not support method
FileMgt.AddStreamToZipStream
and that codeunit 706 ZIP Stream Wrapper does not exist!
How can we manage ZIP files from Cloud?

Hi,
the code above is related to BC12. You are relating to BC16. Have you read the Breaking Changes??

If not - you should! In this document you can see, that the "ZIP Stream Wrapper" was moved to Codeunit "Data Compression".

Hey folks,
I tried using Data Compression codeunit to export multiple files, also managed to export/download zip file however zip file that generated is corrupt. I see that data there in zip file, but cannot open it.
Anybody else facing such issue?

Any news on this topic? We need to download several files in one process too without zipping them. Show a CONFIRM between the files let me download several files but for the user it is annoying.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TinaMenezes picture TinaMenezes  路  3Comments

bvbeek picture bvbeek  路  3Comments

bvbeek picture bvbeek  路  3Comments

ghost picture ghost  路  3Comments

SteveKrisjanovsD365 picture SteveKrisjanovsD365  路  3Comments