uploader
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
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;
|
||||
};
|
||||
Reference in New Issue
Block a user