Skip to content

Commit 21fed04

Browse files
committed
feat(upload): Sync v2 repository
1 parent 77149dc commit 21fed04

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
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: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ async function download(
4343
url: string,
4444
filePath: string,
4545
progressHandler?: ProgressHandler,
46-
headers?: Map<string, string>
46+
headers?: Map<string, string>,
47+
body?: string,
4748
): Promise<void> {
4849
const ids = new Uint32Array(1)
4950
window.crypto.getRandomValues(ids)
@@ -59,8 +60,9 @@ async function download(
5960
url,
6061
filePath,
6162
headers: headers ?? {},
62-
onProgress
63-
})
63+
onProgress,
64+
body: body ?? null,
65+
});
6466
}
6567

6668
export { download, upload }

plugins/upload/src/lib.rs

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

0 commit comments

Comments
 (0)