Created
August 19, 2020 15:18
-
-
Save yossan/25e66361225d1c20b7626343798e3e82 to your computer and use it in GitHub Desktop.
Web/API/FileSystem
This file contains 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> <head> <title>ファイルを書き込む</title> <meta charset="utf-8"> | |
</head> | |
<body> | |
<script> | |
function onInitFs(fs) { | |
fs.root.getFile('log3.txt', {create: true}, function(fileEntry) { | |
// Create a FileWriter object for our FileSystemFileEntry (log.txt). | |
fileEntry.createWriter(function(fileWriter) { | |
fileWriter.onwriteend = function(e) { | |
console.log('Write completed.'); | |
}; | |
fileWriter.onerror = function(e) { | |
console.log('Write failed: ' + e.toString()); | |
}; | |
// Create a new Blob and write it to log.txt. | |
var bb = new Blob(['Hello World'], {type: 'text/plain'}); | |
fileWriter.write(bb); | |
}, (err) => {console.log(err)}); | |
}, (err) => {console.log(err)}); | |
} | |
navigator.webkitPersistentStorage.requestQuota(1024*1024*5, function(bytes) { | |
window.webkitRequestFileSystem(window.PERSISTENT, bytes, onInitFs, (err)=>{console.log(err)}); | |
}) | |
</script> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
filesystem:http://127.0.0.1:8887/persistent/