Can attach file to movement
This commit is contained in:
28
moneymgr_web/src/api/FileApi.ts
Normal file
28
moneymgr_web/src/api/FileApi.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { APIClient } from "./ApiClient";
|
||||
|
||||
export interface UploadedFile {
|
||||
id: number;
|
||||
time_create: number;
|
||||
mime_type: string;
|
||||
sha512: string;
|
||||
file_size: number;
|
||||
file_name: string;
|
||||
user_id: number;
|
||||
}
|
||||
|
||||
export class FileApi {
|
||||
/**
|
||||
* Upload a new file
|
||||
*/
|
||||
static async UploadFile(file: File): Promise<UploadedFile> {
|
||||
const fd = new FormData();
|
||||
fd.append("file", file);
|
||||
return (
|
||||
await APIClient.exec({
|
||||
method: "POST",
|
||||
uri: "/file",
|
||||
formData: fd,
|
||||
})
|
||||
).data;
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@ export interface ServerConstraints {
|
||||
token_max_inactivity: LenConstraint;
|
||||
account_name: LenConstraint;
|
||||
movement_label: LenConstraint;
|
||||
file_allowed_types: string[];
|
||||
}
|
||||
|
||||
export interface LenConstraint {
|
||||
|
Reference in New Issue
Block a user