Home > Mobile >  Download .msg files in client side Reactjs
Download .msg files in client side Reactjs

Time:02-14

I have a server containing multiple .msg files I want to enable the user to download them in the client side using the following code:

const download = (fileName) => {
        var FileSaver = require('file-saver');
        FileSaver.saveAs(constants.filesUploadUrl   fileName, fileName);
    }

The download is working fine with all data types except .msg files It gives me "Failed - No file" enter image description here

Is there a way to enable downloading .msg files in client side?

CodePudding user response:

It turned out that I needed to convert the content type into "application/vnd.ms-outlook" As it wasn't recognized via Google chrome as .msg

My backend ASP.Net Core Code for mapping MIME Type:

 }
            var provider = new FileExtensionContentTypeProvider();
            provider.Mappings[".msg"] = "application/vnd.ms-outlook";
            app.UseStaticFiles(new StaticFileOptions
            {
                FileProvider = new PhysicalFileProvider(
                ContentTypeProvider = provider
            });
  • Related