Skip to content

Commit af98284

Browse files
authored
Merge pull request #1083 from appwrite/fix-functions-sites-files
Chore: Code quality improvement
2 parents 05b53cf + 8c5e764 commit af98284

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

templates/node/src/client.ts.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ class Client {
203203
async chunkedUpload(method: string, url: URL, headers: Headers = {}, originalPayload: Payload = {}, onProgress: (progress: UploadProgress) => void) {
204204
const [fileParam, file] = Object.entries(originalPayload).find(([_, value]) => value instanceof File) ?? [];
205205

206-
if (!file) {
206+
if (!file || !fileParam) {
207207
throw new Error('File not found in payload');
208208
}
209209

@@ -224,7 +224,7 @@ class Client {
224224
const chunk = file.slice(start, end);
225225

226226
let payload = { ...originalPayload };
227-
payload[fileParam ?? ''] = new File([chunk], file.name);
227+
payload[fileParam] = new File([chunk], file.name);
228228

229229
response = await this.call(method, url, headers, payload);
230230

templates/web/src/client.ts.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ class Client {
631631
async chunkedUpload(method: string, url: URL, headers: Headers = {}, originalPayload: Payload = {}, onProgress: (progress: UploadProgress) => void) {
632632
const [fileParam, file] = Object.entries(originalPayload).find(([_, value]) => value instanceof File) ?? [];
633633

634-
if (!file) {
634+
if (!file || !fileParam) {
635635
throw new Error('File not found in payload');
636636
}
637637

@@ -652,7 +652,7 @@ class Client {
652652
const chunk = file.slice(start, end);
653653

654654
let payload = { ...originalPayload };
655-
payload[fileParam ?? ''] = new File([chunk], file.name);
655+
payload[fileParam] = new File([chunk], file.name);
656656

657657
response = await this.call(method, url, headers, payload);
658658

0 commit comments

Comments
 (0)