Skip to content

Commit

Permalink
Added support for file
Browse files Browse the repository at this point in the history
  • Loading branch information
ackava committed Dec 17, 2023
1 parent c424dfd commit b5ae2b3
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/services/FetchBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,18 @@ export default class FetchBuilder {
});
}

public form(name: string, value: string) {
public form(name: string, value: Blob);
public form(name: string, value: Blob, fileName: string);
public form(name: string, value: string | Blob, fileName?: string ) {
const body = this.request.body as FormData ?? new FormData();
body.append(name, value);
if (fileName) {
if (typeof value === "string") {
throw new Error("value must be a blob with content type set correctly.");
}
body.append(name, value as Blob, fileName)
} else {
body.append(name, value);
}
return this.append ({ body });
}

Expand Down

0 comments on commit b5ae2b3

Please sign in to comment.