admin管理员组文章数量:1314514
I am trying to create an offline Todo List in Angular 4.
But I am not able to find any way to store data in a file at Client side using javaScript or Angular.
I am using localStorage of browser right now but it is very slow and it makes my program browser dependent.
please provide a way to create files at client side or any suggestions
I am trying to create an offline Todo List in Angular 4.
But I am not able to find any way to store data in a file at Client side using javaScript or Angular.
I am using localStorage of browser right now but it is very slow and it makes my program browser dependent.
please provide a way to create files at client side or any suggestions
Share Improve this question edited Jun 26, 2018 at 6:54 georgeawg 49k13 gold badges77 silver badges98 bronze badges asked Jun 26, 2018 at 6:41 Ankit HalderAnkit Halder 1691 gold badge4 silver badges18 bronze badges 1- 1 To save you'd have have to generate a file download - and when opening the app you would have to "upload" it to the app (or paste the contents of the file into a textbox that you can load from). As far as I know, there is no way to access the filesystem from JavaScript inside a browser. – fredrik Commented Jun 26, 2018 at 6:44
3 Answers
Reset to default 4To download file or save file
/**
* Method is use to download file.
* @param data - Array Buffer data
* @param type - type of the document.
*/
downLoadFile(data: any, type: string) {
var blob = new Blob([data], { type: type.toString() });
var url = window.URL.createObjectURL(blob);
window.open(url);
}
What you are trying is not possible and it should not be possible for security reasons. I would not expect any webpage would have access to my file system.
If you are building an offline application and it is a desktop app you might try to check electron. But that's only if it is a desktop application, if it runs in the browser then it is just not possible.
We can use IndexDb or websql for offline application.
For more details you can check on following URL
https://www.codeproject./Articles/820391/A-Very-Simple-Example-of-HTML-OFFLINE-Database-ind
Hope this will Help :)
本文标签: javascriptRead and Write to file in angular 4Stack Overflow
版权声明:本文标题:javascript - Read and Write to file in angular 4 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741967243a2407622.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论