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 -2
View File
@@ -13,11 +13,19 @@ interface ProgressPayload {
type ProgressHandler = (progress: ProgressPayload) => void
enum HttpMethod {
Post = 'POST',
Put = 'PUT',
Patch = 'PATCH'
}
async function upload(
url: string,
filePath: string,
progressHandler?: ProgressHandler,
headers?: Map<string, string>
// TODO: V3 - Combine headers and methods into one `options` object
headers?: Map<string, string>,
method?: HttpMethod
): Promise<string> {
const ids = new Uint32Array(1)
window.crypto.getRandomValues(ids)
@@ -33,6 +41,7 @@ async function upload(
url,
filePath,
headers: headers ?? {},
method: method ?? HttpMethod.Post,
onProgress
})
}
@@ -67,4 +76,4 @@ async function download(
})
}
export { download, upload }
export { download, upload, HttpMethod }