1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 21:06:42 +07:00
vault-frontend/src/redux/uploads/api.ts
2021-03-03 12:20:21 +07:00

20 lines
509 B
TypeScript

import { api, cleanResult } from '~/utils/api';
import { API } from '~/constants/api';
import { ApiUploadFileRequest, ApiUploadFIleResult } from '~/redux/uploads/types';
export const apiUploadFile = ({
file,
target = 'others',
type = '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);
};