Aller au contenu

@tauri-apps/plugin-upload

Ce contenu n’est pas encore disponible dans votre langue.

Upload files from disk to a remote server over HTTP, and download files from a remote HTTP server to disk.

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/upload/guest-js/index.ts#L49

The HTTP method used to send the file to the server in upload.

Patch: "PATCH";

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/upload/guest-js/index.ts#L61

Send the file using an HTTP PATCH request.

Post: "POST";

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/upload/guest-js/index.ts#L53

Send the file using an HTTP POST request. This is the default when no method is given.

Put: "PUT";

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/upload/guest-js/index.ts#L57

Send the file using an HTTP PUT request.

function download(
url,
filePath,
progressHandler?,
headers?,
body?
): Promise<void>;

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/upload/guest-js/index.ts#L141

Downloads a file from a given URL and writes it to the given path on disk.

Parameter Type Description
url string The URL to download the file from.
filePath string The path to save the file to. It must include the file name.
progressHandler? ProgressHandler A callback invoked with download progress updates. The reported total will be 0 if the server did not send a Content-Length header or the response body is compressed.
headers? Map<string, string> Additional request headers to send with the download request.
body? string An optional request body. When provided, the download is requested with an HTTP POST request using this value as the body; otherwise an HTTP GET request is used.

Promise<void>

import { download } from '@tauri-apps/plugin-upload';
await download(
'https://example.com/file-download-link',
'./path/to/save/my/file.txt',
({ progress, total }) => console.log(`Downloaded ${progress} of ${total} bytes`),
{ 'Content-Type': 'text/plain' }
);

2.0.0


function upload(
url,
filePath,
progressHandler?,
headers?,
method?
): Promise<string>;

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/upload/guest-js/index.ts#L88

Uploads a file at the given path to a URL, using the file’s contents as the request body.

Parameter Type Description
url string The URL to upload the file to.
filePath string The path of the file to upload.
progressHandler? ProgressHandler A callback invoked with upload progress updates.
headers? Map<string, string> Additional request headers to send with the upload.
method? HttpMethod The HTTP method used to send the file. Defaults to HttpMethod.Post.

Promise<string>

A promise resolving to the response body as text.

import { upload } from '@tauri-apps/plugin-upload';
await upload(
'https://example.com/file-upload',
'./path/to/my/file.txt',
({ progress, total }) => console.log(`Uploaded ${progress} of ${total} bytes`),
{ 'Content-Type': 'text/plain' }
);

2.0.0


© 2026 Tauri Contributors. CC-BY / MIT