upd: dokumen
Deskripsi: - copy file No Issues
This commit is contained in:
22
src/module/_global/fun/copy_file.ts
Normal file
22
src/module/_global/fun/copy_file.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
export async function funCopyFile({ fileId, dirId }: { fileId: string, dirId: string }) {
|
||||
try {
|
||||
const res = await fetch(`https://wibu-storage.wibudev.com/api/files/copy/${dirId}/${dirId}`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ fileId: fileId }),
|
||||
headers: {
|
||||
Authorization: `Bearer ${process.env.WS_APIKEY}`
|
||||
}
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
const hasil = await res.json()
|
||||
return { success: true, data: hasil.data }
|
||||
} else {
|
||||
const errorText = await res.json();
|
||||
return { success: false, data: {} }
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Copy error:", error);
|
||||
return { success: false, data: {} }
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import SkeletonDetailListTugasTask from "./components/skeleton_detail_list_tugas
|
||||
import SkeletonDetailProfile from "./components/skeleton_detail_profile";
|
||||
import SkeletonSingle from "./components/skeleton_single";
|
||||
import WrapLayout from "./components/wrap_layout";
|
||||
import { funCopyFile } from "./fun/copy_file";
|
||||
import { funDeleteFile } from "./fun/delete_file";
|
||||
import { funUploadFile } from "./fun/upload_file";
|
||||
import { WARNA } from "./fun/WARNA";
|
||||
@@ -42,3 +43,4 @@ export { funUploadFile }
|
||||
export { funDeleteFile }
|
||||
export { DIR }
|
||||
export { TEMA }
|
||||
export { funCopyFile }
|
||||
|
||||
Reference in New Issue
Block a user