Skip to content

Commit d831f17

Browse files
committed
Fix file deployment for functions and sites
1 parent 0bdb584 commit d831f17

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

templates/node/src/client.ts.twig

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@ class Client {
201201
}
202202

203203
async chunkedUpload(method: string, url: URL, headers: Headers = {}, originalPayload: Payload = {}, onProgress: (progress: UploadProgress) => void) {
204-
const file = Object.values(originalPayload).find((value) => value instanceof File);
204+
const fileIndex = Object.values(originalPayload).findIndex((value) => value instanceof File);
205+
const fileParam = Object.values(originalPayload)[fileIndex];
206+
const file = originalPayload[fileParam];
205207

206208
if (!file) {
207209
throw new Error('File not found in payload');
@@ -223,7 +225,8 @@ class Client {
223225
headers['content-range'] = `bytes ${start}-${end-1}/${file.size}`;
224226
const chunk = file.slice(start, end);
225227

226-
let payload = { ...originalPayload, file: new File([chunk], file.name)};
228+
let payload = { ...originalPayload };
229+
payload[fileParam] = new File([chunk], file.name);
227230

228231
response = await this.call(method, url, headers, payload);
229232

templates/web/src/client.ts.twig

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,9 @@ class Client {
629629
}
630630

631631
async chunkedUpload(method: string, url: URL, headers: Headers = {}, originalPayload: Payload = {}, onProgress: (progress: UploadProgress) => void) {
632-
const file = Object.values(originalPayload).find((value) => value instanceof File);
632+
const fileIndex = Object.values(originalPayload).findIndex((value) => value instanceof File);
633+
const fileParam = Object.values(originalPayload)[fileIndex];
634+
const file = originalPayload[fileParam];
633635

634636
if (!file) {
635637
throw new Error('File not found in payload');
@@ -651,7 +653,8 @@ class Client {
651653
headers['content-range'] = `bytes ${start}-${end-1}/${file.size}`;
652654
const chunk = file.slice(start, end);
653655

654-
let payload = { ...originalPayload, file: new File([chunk], file.name)};
656+
let payload = { ...originalPayload };
657+
payload[fileParam] = new File([chunk], file.name);
655658

656659
response = await this.call(method, url, headers, payload);
657660

0 commit comments

Comments
 (0)