Document in byte array to local file from Web Client

90 Views Asked by At

On user input, I get the byte array from the cloud (Document in various format) and then I save this byte array as a document in included format. The code runs on desktop client and in Web client (the app runs on the server and method is called from web application of the tool)

I have .NET Framework (4.8) Project. Project is extension for BI tool Spotfire. The source code of the projects runs on desktop client and web client as I mentioned. In desktop client I use standard functionality with SaveFileDialog class and it works fine. For Web client I have problem because I cannot open dialogs and cannot save the file to local path because it run on server and web application.

SaveFileDialog save = new SaveFileDialog();

                save.FileName = documentName;

                switch (documentInfo.type)
                {
                    case MIME_PDF:
                        save.Filter = "PDF(*.pdf)|*.pdf";
                        break;
                    case MIME_DOC:
                        save.Filter = "Word document|*.doc";
                        break;
                    case MIME_DOCX:
                        save.Filter = "DOCX document|*.docx";
                        break;
                    case MIME_XLS:
                        save.Filter = "XLS document|*.xls";
                        break;
                    case MIME_XLSX:
                        save.Filter = "XLSX document|*.xlsx";
                        break;
                }

                if (save.ShowDialog() == DialogResult.OK)
                {
                    byte[] bytes = AWSInvoker.GetS3Document(documentInfo.id);
                    File.WriteAllBytes(save.FileName, bytes);));
                }

This is the code for desktop client. What I need to do in case when it runs on web client: -> Get the bytes -> Download it from Web browser to local storage -> I have to avoid to store content on server storage but directly run downloading from Web Browser

The application is not ASP.NET and I cannot capture this functionality in JavaScript or any other front end framework

0

There are 0 best solutions below