M
M
Maxim Kuprashevich2014-09-17 17:01:10
JavaScript
Maxim Kuprashevich, 2014-09-17 17:01:10

How to create and write files in JavaScript from Chrome Extension?

Hi all. I had a problem: I need to perform fairly simple actions - create and write files to the specified path, but it is also possible in chrome storage, from a script in chrome extension. The problem is that a couple of hours in Google did not give any result - there are some complicated options everywhere, like creating an additional Chrome app and messaging with it. Is there a less complicated way? I'm already very tired, although all I want is to save data for myself, it's not clear why this is so difficult.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
ProjectSoft, 2015-12-24
@UndeadDragon

Everything is perfectly saved via chrome.downloads.download
As an example, save the full localStorage extension

var result = JSON.stringify(localStorage,"", 4),
  obj = {
    "filename": "localStorage.json",
    "url": 'data:application/json;charset=utf-8,' + encodeURIComponent(result),
    "conflictAction": "prompt",
    "saveAs": true
  };
chrome.downloads.download(obj);

This will definitely show the window "Save as ..."
Smoke here chrome.downloads

A
Alexander Taratin, 2014-09-17
@Taraflex

I'm already very tired, although all I want is to save data for myself, it's not clear why this is so difficult.

Store information in localstorage. It simply cannot be saved to a file.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question