Skip to content

Commit b87ae49

Browse files
committed
fix: file can be undefined warning
1 parent 9e89b0b commit b87ae49

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

templates/node/src/client.ts.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ class Client {
200200
async chunkedUpload(method: string, url: URL, headers: Headers = {}, originalPayload: Payload = {}, onProgress: (progress: UploadProgress) => void) {
201201
const file = Object.values(originalPayload).find((value) => value instanceof File);
202202

203+
if (!file) {
204+
throw new Error('No file found in payload');
205+
}
206+
203207
if (file.size <= Client.CHUNK_SIZE) {
204208
return await this.call(method, url, headers, originalPayload);
205209
}

templates/web/src/client.ts.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,10 @@ class Client {
621621
async chunkedUpload(method: string, url: URL, headers: Headers = {}, originalPayload: Payload = {}, onProgress: (progress: UploadProgress) => void) {
622622
const file = Object.values(originalPayload).find((value) => value instanceof File);
623623

624+
if (!file) {
625+
throw new Error('No file found in payload');
626+
}
627+
624628
if (file.size <= Client.CHUNK_SIZE) {
625629
return await this.call(method, url, headers, originalPayload);
626630
}

0 commit comments

Comments
 (0)