Reputation: 305
I've successfully stored data using FILESYSTEM API provided by HTML5. But I don't know where I could identify the file in my local repository so that I can backup the data I stored. I have also check my root directory of application in the server (Tomcat 7.0), but I couldn't find the file. While using chrome developer tools, I checked the data is storing successfully.
The Code goes like this:
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
function onInitFs(fs)
{
fs.root.getFile('fpslog.txt', {create: false}, function(fileEntry) {
// Create a FileWriter object for our FileEntry (log.txt).
fileEntry.createWriter(function(fileWriter) {
fileWriter.seek(fileWriter.length); // Start write position at EOF.
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(['Hello World'], {type: 'text/plain'});
fileWriter.write(blob);
}, errorHandler);
}, errorHandler);
}
window.requestFileSystem(window.TEMPORARY, 5*1024*1024 /*5MB*/, onInitFs, errorHandler);
and the ERROR function:
function errorHandler(e) {
var msg = '';
switch (e.code) {
case FileError.QUOTA_EXCEEDED_ERR:
msg = 'QUOTA_EXCEEDED_ERR';
break;
case FileError.NOT_FOUND_ERR:
msg = 'NOT_FOUND_ERR';
break;
case FileError.SECURITY_ERR:
msg = 'SECURITY_ERR';
break;
case FileError.INVALID_MODIFICATION_ERR:
msg = 'INVALID_MODIFICATION_ERR';
break;
case FileError.INVALID_STATE_ERR:
msg = 'INVALID_STATE_ERR';
break;
default:
msg = 'Unknown Error';
break;
};
console.log('Error: ' + msg);
}
In developer tools, I did see no error print rather it is saying 'write completed', which means i'm able to create file somewhere and storing the data. I want to get to access that data to view. As already the tutorial mentioned, I don't see any file created in root folder. Any Help Please.
Upvotes: 2
Views: 1434
Reputation: 24109
You can also view the files using the root directory's filesystem:
URL. Open
filesystem:<YOUR_ORIGIN>/temporary/
in the address bar, replacing with the origin your app is running off of (e.g. "http://stackoverflow.com").
You can also enable "FileSystem inspection" in the DevTools under experiments. This may also require you to "Enable Experimental DevTools features" in about:flags
.
Upvotes: 2
Reputation: 305
I found out way, using google chrome plugin which helps you to view the content of filesystem API of HTML5.
Upvotes: 0