Problem saving blobs to a file with .xml extension

Issue #13751238 • Assigned to Steven K.

Details

Author
Cezary K.
Created
Sep 14, 2017
Privacy
This issue is public.
Found in
  • Microsoft Edge
Found in build #
15.15063
Reports
Reported by 1 person

Sign in to watch or report this issue.

Steps to reproduce

Saving a blob to a file with “.xml” extension does not work. Changing the code below to save to a file with .txt works.

var data = "<?xml version=’1.0’ encoding=’UTF-8’?>";

// 1. this will give “test.xml couldn’t be downloaded error”
navigator.msSaveBlob(new Blob([data], “text/xml”), “test.xml”);

// 2 this will give “test.xml couldn’t be downloaded error”
let a = document.createElement(‘a’);
a.href = window.URL.createObjectURL(new Blob([data], “text/xml”));
a.download = "test.xml";
document.body.appendChild(a);
a.click();

Attachments

2 attachments

Comments and activity

  • Microsoft Edge Team

    Changed Assigned To to “Steven K.”

  • Hi Cezary,

    Have you tried using window.navigator.msSaveBlob()?
    var
    blobObject
    = new
    Blob
    (["<?xml version=’1.0’ encoding=’UTF-8’?>
    \r
    "

    •   "<CATALOG>
      

    \r
    "

    •   "<PLANT><COMMON>Bloodroot</COMMON><BOTANICAL>Sanguinaria canadensis</BOTANICAL></PLANT>
      

    \r
    "

    •   "<PLANT><COMMON>Columbine</COMMON><BOTANICAL>Aquilegia canadensis</BOTANICAL></PLANT>
      

    \r
    "

    •    "</CATALOG>
      

    \r
    "

    ]);

    window
    .navigator
    .msSaveBlob(blobObject
    , ‘msSaveBlob_testFile.xml’
    );
    I have attached my complete example. Here is the link I used as a reference.
    https://docs.microsoft.com/en-us/microsoft-edge/dev-guide/html5/file-api/blob

    Let me know what you find,
    Steve

  • Yes I did, as you can see in the example above I have tried both: 1. Using msSaveBlob & 2. Using a link. Same error in both cases

  • In your example, you are using navigator.msSaveBlob.  That is for IE, I believe.

    Can you run the repro I attached and let me know the results?

  • If I run index.html by clicking the attachment -> works
    If I save index.html to desktop first before running it -> fails

  • Perhaps there is a file permission issue?  Can you make sure the downloaded and saved ‘index.html’ is unblocked?  I have attached a screenshot of the unlock option.  Right click on the file and select properties to get to this screen.

  • It’s definitely not blocked since I can change the extension back and forth “.xml” not working, “.txt” working.

You need to sign in to your Microsoft account to add a comment.

Sign in