Skip to content

Commit 0d3a3f4

Browse files
committed
fix optional value
1 parent bf6d977 commit 0d3a3f4

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

.changes/feat-download-on-post.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
upload: patch
3+
upload-js: patch
34
---
45

56
Added post request on download function

plugins/upload/api-iife.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/upload/guest-js/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ async function download(
4646
filePath: string,
4747
progressHandler?: ProgressHandler,
4848
headers?: Map<string, string>,
49-
body?: string,
49+
body?: string
5050
): Promise<void> {
5151
const ids = new Uint32Array(1)
5252
window.crypto.getRandomValues(ids)
@@ -63,8 +63,8 @@ async function download(
6363
filePath,
6464
headers: headers ?? {},
6565
onProgress,
66-
body: body ?? null,
67-
});
66+
body: body
67+
})
6868
}
6969

7070
export { download, upload }

plugins/upload/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@
2525
"LICENSE"
2626
],
2727
"dependencies": {
28-
"@tauri-apps/api": "^2.0.3"
28+
"@tauri-apps/api": "^2.0.0"
2929
}
3030
}

plugins/upload/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ async fn download(
7070
file_path: &str,
7171
headers: HashMap<String, String>,
7272
on_progress: Channel<ProgressPayload>,
73-
body: String,
73+
body: Option<String>,
7474
) -> Result<()> {
7575
let client = reqwest::Client::new();
76-
let mut request = if !body.is_empty() {
77-
client.post(url).body(body.to_owned())
76+
if let Some(body) = body {
77+
client.post(url).body(body)
7878
} else {
7979
client.get(url)
8080
};

0 commit comments

Comments
 (0)