tauri-apps / tauri

Build smaller, faster, and more secure desktop applications with a web frontend.
https://tauri.app
Apache License 2.0
81.61k stars 2.44k forks source link

[feat] Download file able on mobile. #10280

Open mikoto2000 opened 1 month ago

mikoto2000 commented 1 month ago

Describe the problem

Android cannot download/create a file. (To be precise, there is an API to create it, but there is no way to know the path, so it is impossible to know the path that can be saved.)

If you download from a link, the file will be stored in the download directory, so the app doesn't need to know the path, and I thought it would be easy for users to understand as it would be a familiar behavior.

So, I try create blob link and click this link on Android. but it cannot download.

Blob link creation.

      let data = JSON.stringify(logs);
      const blob = new Blob([data], { type: 'text/plain' });
      const blobUrl = URL.createObjectURL(blob);
      setDataBlobUrl(blobUrl);

and link creation.

              <a
                href={dataBlobUrl}
                download={"worklog." + exportType}
                onClick={() => {
                  setTimeout(() => {
                    URL.revokeObjectURL(dataBlobUrl);
                    setDataBlobUrl(null);
                  }, 0);
                }}>ダウンロード</a>

additional try.

  1. delete download attribute from 'a' tag : can view data on WebView
  2. add download attribute for 'a' tag : can not download

Describe the solution you'd like

Not limited to Blob links, I would like to download files to the mobile device's file system from a Tauri application by some method.

Alternatives considered

fs plugin's save dialog. but it is not implement on mobile.

Additional context

No response

mikoto2000 commented 1 month ago

Related issues (but no mention of mobile):

Related issues(alternative solution):