tauri: [bug] Can not download in front end

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

Temporary solution:

import { saveAs } from 'file-saver';
import { save } from '@tauri-apps/api/dialog';
import { writeTextFile } from '@tauri-apps/api/fs';

export const downloadFile = async (filename, text, type = 'application/json') => {
    if (window.__TAURI__) {
        const filePath = await save({ defaultPath: filename });
        await writeTextFile(filePath, text);
    } else {
        saveAs(new Blob([text], { type }), filename);
    }
};

Don’t forget to enable dialogs.

Is there any plan for this being added to tauri still? It’s still not working in tauri 1.4 almost one year after it being fixed upstream (it was planned apparently to be added to tauri 1.3). It’s quite a critical issue for us.

My experience of the out of the box behaviour of downloads (Tauri 1.3.0):

  • On Windows, files are downloaded to the downloads folder. The web view shows a notification. If the file already exists, the new file is saved with a unique name.
  • On Linux (Ubuntu 22.04), files are downloaded to the downloads folder. There is no notification from the web view. If the file already exists, it’s deleted and no new file is saved.

(I don’t have access to macOS to test there.)

On macOS nothing seems to happen at all. No errors in the console, no file is downloaded.

At least not to this locations:

  • Desktop
  • Documents
  • User Folder ~/

It looks like this has been solved upstream. Has that made it into any releases for tauri? Are there any workarounds?

@FabianLars Would be useful to know if this issue is likely to be fixed in the 2.0 release.

it still needs to be implemented in Tauri. wry#530 just made it possible to do so (by adding new apis). 530 by itself shouldn’t have added any behavior changes outside these new apis.