AL icon indicating copy to clipboard operation
AL copied to clipboard

DownloadFromStream with multiple files in Web Client

Open OleTeichmann opened this issue 8 years ago • 25 comments

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;

OleTeichmann avatar Sep 05 '18 13:09 OleTeichmann

Is this question related to NAv 2018?

kalberes avatar Sep 05 '18 22:09 kalberes

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

AL Compiler: 0.16.19969

dNsl9r avatar Sep 06 '18 06:09 dNsl9r

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;

judecot avatar Sep 06 '18 11:09 judecot

@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.

dNsl9r avatar Sep 07 '18 07:09 dNsl9r

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

thpeder avatar Nov 07 '18 09:11 thpeder

This has been added to the client team backlog.

StanislawStempin avatar Nov 07 '18 10:11 StanislawStempin

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

TharunMuthu avatar Jul 02 '19 00:07 TharunMuthu

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..!

judecot avatar Jul 02 '19 06:07 judecot

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)

achecac avatar Apr 23 '20 23:04 achecac

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?

achecac avatar Apr 26 '20 21:04 achecac

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".

dNsl9r avatar Apr 27 '20 05:04 dNsl9r

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?

anagpal1990 avatar Apr 28 '20 17:04 anagpal1990

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.

redIT-LoPf avatar Aug 13 '20 07:08 redIT-LoPf

In codeunit 242 there are code to print two reports from itemreg and whsreg, respective. But Only print the second record. This is standar functionality, its necessary solution.

rdiazbla avatar Feb 05 '21 14:02 rdiazbla

update currenly download multiple file and save report to pdf mutifile not working in Version: W1 17.3 (Platform 17.0.20458.24191 + Application 17.3.20469.22477) , have any idea ?

Nutzaru533 avatar Apr 22 '21 12:04 Nutzaru533

Please try using Compression Mgt. to zip and download files in single zip.. it works just fine.

anagpal1990 avatar Apr 22 '21 17:04 anagpal1990

Or you remove the code for printing multiple documents, for example in warehouse shipment post or get a solution for it. Two years it's a of of time

nunogsilva avatar Jul 07 '21 09:07 nunogsilva

On Yammer, Andreas Glöckner indicates that changing your browser/settings might enable multiple downloads to work:

But sometimes the browser ask like "the website is triying to download mulitple files. Do you want to allow that?". I think that would be more practial.

Nevertheless, with your answer I looked up my browser (edge) settings and could find a solution that may makes it easier. Want to share it here:

Search for "automatic download" ("automatische downloads").

The first settings says exactly what I wrote in the beginning (see screenshot) but it is not considered by BC? Maybe another setting or a "bug"?

I just added my localhost to allow multiple downloads and suddenly my client downloads multiple files simultaneously :)

Hope this might help.

image

Both these issues say this is on the client team's backlog. I don't know whether that's still the case, whether they know about this setting, etc. - but maybe it's not fully under their control?

dzzzb avatar Sep 29 '21 13:09 dzzzb

Any news? Allot of customers lauth about BC or don't belive us.

ReneGubler avatar Apr 04 '22 11:04 ReneGubler

Hi microsoft/al ,

Thank you for your help !! , i will try to do , this case i have to talk with client already , so they will do another way .

Best regards Jirayut (ken)

On Mon, 4 Apr 2565 BE at 18:05 René Gubler @.***> wrote:

Any news? Allot of customers lauth about BC or don't belive us.

— Reply to this email directly, view it on GitHub https://github.com/microsoft/AL/issues/3575#issuecomment-1087416619, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHZGXXJFEECCINPN4PGUTGTVDLEIBANCNFSM4FTLZNOQ . You are receiving this because you commented.Message ID: @.***>

Nutzaru533 avatar Apr 04 '22 12:04 Nutzaru533