Skip to content

Instantly share code, notes, and snippets.

@gauravmehla
Last active September 13, 2017 15:54
Show Gist options
  • Select an option

  • Save gauravmehla/9bd54d58a5bb76929f1fbc31a8a2d67a to your computer and use it in GitHub Desktop.

Select an option

Save gauravmehla/9bd54d58a5bb76929f1fbc31a8a2d67a to your computer and use it in GitHub Desktop.
function savebase64AsFile(folderPath, fileName, base64, contentType){
var DataBlob = b64toBlob(base64,contentType);
window.resolveLocalFileSystemURL(folderPath, function(dir) {
dir.getFile(fileName, {create:true}, function(file) {
file.createWriter(function(fileWriter) {
fileWriter.write(DataBlob);
fileWriter.onwrite = function(){
console.log('File written successfully.');
}
}, function(){
alert('Unable to save file in path '+ folderPath);
});
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment