wip fix
This commit is contained in:
parent
e4e2ca7616
commit
f1180c2966
|
|
@ -69,16 +69,24 @@ export const fetchViaProxy = async (
|
||||||
(Array.isArray(data) && data[0] instanceof File)
|
(Array.isArray(data) && data[0] instanceof File)
|
||||||
) {
|
) {
|
||||||
const target = new URL(url);
|
const target = new URL(url);
|
||||||
|
_headers["content-type"] = "multipart/form-data";
|
||||||
if (data instanceof File) {
|
if (data instanceof File) {
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("file", data);
|
||||||
const res = await fetch(target.pathname, {
|
const res = await fetch(target.pathname, {
|
||||||
body: data,
|
body: formData,
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: _headers,
|
headers: _headers,
|
||||||
});
|
});
|
||||||
return await res.text();
|
return await res.text();
|
||||||
} else {
|
} else {
|
||||||
|
const formData = new FormData();
|
||||||
|
let idx = 1;
|
||||||
|
for (const file of data) {
|
||||||
|
formData.append("file-" + idx++, file);
|
||||||
|
}
|
||||||
const res = await fetch(target.pathname, {
|
const res = await fetch(target.pathname, {
|
||||||
body: data[0],
|
body: formData,
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: _headers,
|
headers: _headers,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue