-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfs.html
More file actions
46 lines (36 loc) · 1.53 KB
/
fs.html
File metadata and controls
46 lines (36 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<html>
<head>
<script>
function onInitFs(fs) {
fs.root.getFile('log.txt', {create: true}, function(fileEntry) {
// fileEntry.isFile === true
// fileEntry.name == 'log.txt'
// fileEntry.fullPath == '/log.txt'
alert('ble');
// Create a FileWriter object for our FileEntry (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 blob = new Blob(['Lorem Ipsum'], {type: 'text/plain'});
fileWriter.write(blob);
alert('written');
});
}, errorHandler);
}
function errorHandler(err) { alert(err.name); }
function init()
{
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
window.requestFileSystem(window.TEMPORARY, 1024*1024, onInitFs, errorHandler);
}
</script>
</head>
<body>
<input type="button" value="START!" onclick="init()"/>
</body>
</html>