Skip to content

Commit 36347ed

Browse files
authored
Merge pull request #63 from JigsawStack/fix/file-upload-multiform
2 parents 0de2a77 + ea07b3f commit 36347ed

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

src/store/file.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
11
import { BaseResponse } from "../../types";
22
import { respToFileChoice } from "../helpers";
33
import { RequestClient } from "../request";
4+
import { createFileUploadFormData } from "../utils";
45
import { FileUploadParams, FileUploadResponse } from "./interfaces/file";
56
export class File {
67
constructor(private readonly client: RequestClient) {}
78

89
upload = async (file: Blob | Buffer, params?: FileUploadParams): Promise<FileUploadResponse> => {
9-
return await this.client.fetchJSS(
10-
`/v1/store/file`,
11-
"POST",
12-
file,
13-
{
14-
key: params?.key,
15-
overwrite: params?.overwrite,
16-
temp_public_url: params?.temp_public_url,
17-
},
18-
params?.content_type && {
19-
"Content-Type": params.content_type,
20-
}
21-
);
10+
const formData = createFileUploadFormData(file, params);
11+
12+
return await this.client.fetchJSS(`/v1/store/file`, "POST", formData);
2213
};
2314

2415
retrieve = async (key: string) => {

0 commit comments

Comments
 (0)