feat(upload): Add HTTP method selection for upload (#2991)

Co-authored-by: Fabian-Lars <github@fabianlars.de>
This commit is contained in:
Matthew Richardson
2025-11-10 20:31:57 +00:00
committed by GitHub
parent 6b854421a1
commit ad910b1135
6 changed files with 132 additions and 23 deletions
+11 -1
View File
@@ -60,14 +60,24 @@ fn main() {
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
```javascript
import { upload } from '@tauri-apps/plugin-upload'
import { upload, HttpMethod } from '@tauri-apps/plugin-upload'
// Upload with default POST method
upload(
'https://example.com/file-upload',
'./path/to/my/file.txt',
(progress, total) => console.log(`Uploaded ${progress} of ${total} bytes`), // a callback that will be called with the upload progress
{ 'Content-Type': 'text/plain' } // optional headers to send with the request
)
// Upload with specific HTTP method
upload(
'https://example.com/file-upload',
'./path/to/my/file.txt',
(progress, total) => console.log(`Uploaded ${progress} of ${total} bytes`),
{ 'Content-Type': 'text/plain' },
HttpMethod.Put // Use HttpMethod enum - supports POST, PUT, PATCH
)
```
```javascript