Loading file from DataURL in JavaScript

From this line we get from DataURL, what is the best way to load this as a file?

So far, I got the base window.open("myDataURL"); but I cannot change the file name this way.

 window.open('data:application/msword;base64,0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAA PgADAP7/CQAGAAAAAAAAAAAAAAACAAAANQAAAAAAA AAAEAAANwAAAAIAAAD+////AAAAADQAAABsAA/', '_blank','height=300,width=400'); 

I was wondering if there is a way to properly process this data.

+7
source share
2 answers

you can add a loading attribute to the anchor element. Sample:

 <a download="abcd.zip" href="data:application/stream;base64,MIIDhTCCAvKg........">download</a> 
+3
source

Try the following:

 data:application/msword;fileName=test.doc;base64,0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAACAAAANQAAAAAAAAAAEAAANwAAAAIAAAD+////AAAAADQAAABsAA/ 

But this is just an assumption from googling around and may be browser dependent. The real answer to this question is: you cannot - see http://www.ietf.org/rfc/rfc2397 for reference, there is nothing in the specification to support the file name.

0
source

All Articles