Writing to a file from a Chrome packaged app
Ad
Below is the code with which I am trying to write to a simple text file from a Chrome App.
Once createWriter
is invoked, nothing happens. Can't get it working, any inputs on this is appreciated.
chrome.fileSystem.chooseEntry({type: 'saveFile'},
function(writableFileEntry) {
writableFileEntry.createWriter(function(writer) {
writer.onwriteend = function(e){
console.log("save completed!!");
};
writer.onerror = function(e){
console.log("save failed!!");
};
writer.write(new Blob(["Hello World!!!"],{type: 'text/plain'}));
}, errorHandler);
});
Mainifest.json
{
"name": "FileIO",
"version": "1.0",
"manifest_version": 2,
"minimum_chrome_version": "23",
"app": {
"background": {
"scripts": ["background.js", "myscript.js"]
}
},
"icons": {
"128": "icon.png"
},
"permissions": [
"fileSystem",
{"fileSystem" : ["write","retainEntries", "directory"] }
],
"file_handlers": {
"text": {
"types": [
"text/*"
]
}
}
}
Ad
Answer
Ad
errorHandler function was defined out of scope and was causing the issue, moving the errorHandler function inside the scope fixed the issue! Thanks to Xan for helping with troubleshooting.
Ad
source: stackoverflow.com
Related Questions
Ad
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
Ad