Fixed upload headers
This commit is contained in:
parent
af887a0bfb
commit
75160b7dbc
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ztimson/utils",
|
"name": "@ztimson/utils",
|
||||||
"version": "0.14.4",
|
"version": "0.14.5",
|
||||||
"description": "Utility library",
|
"description": "Utility library",
|
||||||
"author": "Zak Timson",
|
"author": "Zak Timson",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -43,12 +43,12 @@ export function uploadWithProgress<T>(options: {
|
|||||||
options.files.forEach(f => formData.append('file', f));
|
options.files.forEach(f => formData.append('file', f));
|
||||||
|
|
||||||
xhr.withCredentials = !!options.withCredentials
|
xhr.withCredentials = !!options.withCredentials
|
||||||
Object.entries(options.headers || {}).forEach(([key, value]) => xhr.setRequestHeader(key, value));
|
|
||||||
xhr.upload.addEventListener('progress', (event) => event.lengthComputable ? prog(event.loaded / event.total) : null);
|
xhr.upload.addEventListener('progress', (event) => event.lengthComputable ? prog(event.loaded / event.total) : null);
|
||||||
xhr.upload.addEventListener('load', (resp) => res(<any>resp));
|
xhr.upload.addEventListener('load', (resp) => res(<any>resp));
|
||||||
xhr.upload.addEventListener('error', (err) => rej(err));
|
xhr.upload.addEventListener('error', (err) => rej(err));
|
||||||
|
|
||||||
xhr.open('POST', options.url);
|
xhr.open('POST', options.url);
|
||||||
|
Object.entries(options.headers || {}).forEach(([key, value]) => xhr.setRequestHeader(key, value));
|
||||||
xhr.send(formData);
|
xhr.send(formData);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user