Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular4/5: how to create folder, text file and write data into that file using typescript

I need to create folder, text file and write data into that file in angular5 using typescript.This is to write errors in text file. Is it possible in angular?

Thanks in advance.

like image 978
kamalav Avatar asked Dec 28 '17 05:12

kamalav


1 Answers

Like Osman Cea said, this can not be done on client side. You can create file using Blob and URL.createObjectURL. But you can not save the file, since that would raise large security problems.

Since you want to record errors, you can post error to server and there store it to database or file system. That means you need some framework on the server side like PHP, ASP.NET Core ...

If you use Google analytics, another option (if you really want to avoid server framework which I do not recommend) is to use Google Analytics API. I once log client side errors to Google analytics with API.

ga('send', {
  hitType: 'event',
  eventCategory: 'Error',
  eventAction: window.location.href,
  eventLabel: your_error_object
});
like image 122
Makla Avatar answered Nov 15 '22 05:11

Makla