2017-07-09 7 views

Antwort

0

Sie diese einfache Download-Funktion nutzen können, die URL es passieren, Dateinamen, den Sie möchten, und der Typ.

function download(url, filename, mimeType){ 
     return (fetch(url) 
      .then(function(res){return res.arrayBuffer();}) 
      .then(function(buf){return new File([buf], filename, {type:mimeType});}) 
     ); 
    } 

    download('data:text/plain;base64,aGVsbG8gd29ybGQ=', 'hello.txt', 'text/plain') 
    .then(function(file){ 
     console.log(file); 
    }) 
0

Ich schlage vor, Sie verwenden download.js Bibliothek. Fügen Sie diese Bibliothek hinzu und versuchen Sie den folgenden Code mit dem Bildmime-Typ:

<a href="javascript:download(atob('*base64bytestring*'), 'dlText.txt', 'text/plain');" >untitled.txt</a>