@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.
Enumerations
Section titled “Enumerations”HttpMethod
Section titled “HttpMethod”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.
Enumeration Members
Section titled “Enumeration Members”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.
Functions
Section titled “Functions”download()
Section titled “download()”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.
Parameters
Section titled “Parameters”| 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. |
Returns
Section titled “Returns”Promise<void>
Example
Section titled “Example”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
upload()
Section titled “upload()”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.
Parameters
Section titled “Parameters”| 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. |
Returns
Section titled “Returns”Promise<string>
A promise resolving to the response body as text.
Example
Section titled “Example”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