Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

downloads.download deletes file?

  • Amul benn tontu
  • 0 am na jafe-jafe bii
more options

I'm writing an extendion wich needs to download a file:

```js

   let url = URL.createObjectURL(new Blob([content + '\n']));
   try {
       const id = await browser.downloads.download(
           {
               filename: "some_name",
               saveAs: false,
               conflictAction: "overwrite",
               url: url
           }
       );
       await browser.downloads.erase({id: id});
   } finally {
       URL.revokeObjectURL(url);
   }

```

If the file does not exist yet, it works great. If the file exists but is exactly the same, it still works. But if there is a need to override the file with different content, the file gets deleted and it is not being replaced.

According to inotifywait, the new file IS created, but immediately deleted.

Do I understand something wrong? What am I supposed to do?

I'm writing an extendion wich needs to download a file: ```js let url = URL.createObjectURL(new Blob([content + '\n'])); try { const id = await browser.downloads.download( { filename: "some_name", saveAs: false, conflictAction: "overwrite", url: url } ); await browser.downloads.erase({id: id}); } finally { URL.revokeObjectURL(url); } ``` If the file does not exist yet, it works great. If the file exists but is exactly the same, it still works. But if there is a need to override the file with different content, the file gets deleted and it is not being replaced. According to inotifywait, the new file IS created, but immediately deleted. Do I understand something wrong? What am I supposed to do?

You must log in to your account to reply to posts. Please start a new question, if you do not have an account yet.