Created
March 16, 2022 19:22
-
-
Save bradkrane/6bcf1aa9f1343d1f114ef5b8b39a7410 to your computer and use it in GitHub Desktop.
Paste Base64 and Save As...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<p><h2>Base64 to file</h2></p> | |
<p> | |
Get data with: <pre>cat <file> | gzip -c | base64</pre><br/> | |
Paste below and save to file: | |
</p> | |
<p> | |
<textarea id="content" style="width: 580px; height: 250px;"></textarea> | |
<br/> | |
<input type="text" id="filename" value="case-file.gz"/><input type="button" id="btn" value="Download" /> | |
</p> | |
<script> | |
function downloadBase64(filename, base64) { | |
// create 'link' to a 'file' for download | |
var el = document.createElement('a'); | |
el.setAttribute('href', `data:application/gzip;base64,${encodeURIComponent(base64)}`); | |
el.setAttribute('download', filename); | |
document.body.appendChild(el); | |
el.click(); | |
document.body.removeChild(el); | |
} | |
// do dl | |
document.getElementById("btn").addEventListener("click" | |
,()=>{ downloadBase64(document.getElementById("filename").value.trim(), document.getElementById("content").value.trim());} | |
, false); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment