32 lines
724 B
TypeScript
32 lines
724 B
TypeScript
import axios from "@/config/axios";
|
|
import type {
|
|
SingleUploadResponse,
|
|
MultipleUploadResponse,
|
|
} from "../types/Types";
|
|
|
|
export const singleUpload = async (
|
|
file: File
|
|
): Promise<SingleUploadResponse> => {
|
|
const formData = new FormData();
|
|
formData.append("file", file);
|
|
const { data } = await axios.post<SingleUploadResponse>(
|
|
`/admin/single-file`,
|
|
formData
|
|
);
|
|
return data;
|
|
};
|
|
|
|
export const multipleUpload = async (
|
|
files: File[]
|
|
): Promise<MultipleUploadResponse> => {
|
|
const formData = new FormData();
|
|
files.forEach((file) => {
|
|
formData.append("files", file);
|
|
});
|
|
const { data } = await axios.post<MultipleUploadResponse>(
|
|
`/admin/multi-file`,
|
|
formData
|
|
);
|
|
return data;
|
|
};
|