1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 12:56:41 +07:00

removed upload redux store

This commit is contained in:
Fedor Katurov 2022-01-06 21:04:14 +07:00
parent 140e36b6b7
commit 95b92b643f
38 changed files with 398 additions and 691 deletions

21
src/api/uploads/index.ts Normal file
View file

@ -0,0 +1,21 @@
import { api, cleanResult } from '~/utils/api';
import { API } from '~/constants/api';
import { ApiUploadFileRequest, ApiUploadFIleResult } from '~/api/uploads/types';
import { UploadTarget, UploadType } from '~/constants/uploads';
export const apiUploadFile = ({
file,
target = UploadTarget.Others,
type = UploadType.Image,
onProgress,
}: ApiUploadFileRequest) => {
const data = new FormData();
data.append('file', file);
return api
.post<ApiUploadFIleResult>(API.USER.UPLOAD(target, type), data, {
onUploadProgress: onProgress,
})
.then(cleanResult);
};

11
src/api/uploads/types.ts Normal file
View file

@ -0,0 +1,11 @@
import { IFile, IUploadProgressHandler } from '~/redux/types';
import { UploadTarget, UploadType } from '~/constants/uploads';
export type ApiUploadFileRequest = {
file: File;
type: UploadType;
target: UploadTarget;
onProgress: IUploadProgressHandler;
};
export type ApiUploadFIleResult = IFile;