Skip to content

Commit 4708fcd

Browse files
committed
feat(upload): Added post to download function
1 parent bc834d4 commit 4708fcd

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ async function download(
4444
filePath: string,
4545
progressHandler?: ProgressHandler,
4646
headers?: Map<string, string>,
47+
body?: string,
4748
): Promise<void> {
4849
const ids = new Uint32Array(1);
4950
window.crypto.getRandomValues(ids);
@@ -60,6 +61,7 @@ async function download(
6061
filePath,
6162
headers: headers ?? {},
6263
onProgress,
64+
body: body ?? "",
6365
});
6466
}
6567

plugins/upload/src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,14 @@ async fn download(
6666
file_path: &str,
6767
headers: HashMap<String, String>,
6868
on_progress: Channel,
69+
body: &str,
6970
) -> Result<()> {
7071
let client = reqwest::Client::new();
71-
72-
let mut request = client.get(url);
72+
let mut request = if !body.is_empty() {
73+
client.post(url).body(body.to_owned())
74+
} else {
75+
client.get(url)
76+
};
7377
// Loop trought the headers keys and values
7478
// and add them to the request object.
7579
for (key, value) in headers {

0 commit comments

Comments
 (0)