fix: view pdf
This commit is contained in:
22
src/module/_global/fun/read_pdf.ts
Normal file
22
src/module/_global/fun/read_pdf.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
export async function funReadPdf({ file, page }: { file: string, page:number }) {
|
||||
try {
|
||||
const res = await fetch(`https://wibu-storage.wibudev.com/api/pdf-to-image?url=https://wibu-storage.wibudev.com/api/files/${file}&pages=${page}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: `Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjp7ImlkIjoiY20wdnQ4bzFrMDAwMDEyenE1eXl1emd5YiIsIm5hbWUiOiJhbWFsaWEiLCJlbWFpbCI6ImFtYWxpYUBiaXAuY29tIiwiQXBpS2V5IjpbeyJpZCI6ImNtMHZ0OG8xcjAwMDIxMnpxZDVzejd3eTgiLCJuYW1lIjoiZGVmYXVsdCJ9XX0sImlhdCI6MTcyNTkzNTE5MiwiZXhwIjo0ODgxNjk1MTkyfQ.7U-HUnNBDmeq_6XXohiFZjFnh2rSzUPMHDdrUKOd7G4`
|
||||
// Authorization: `Bearer ${process.env.WS_APIKEY}`
|
||||
}
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
const hasil = await res.json()
|
||||
return { success: true, data: hasil }
|
||||
} else {
|
||||
const errorText = await res.text();
|
||||
return { success: false, data: {} }
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Upload error:", error);
|
||||
return { success: false, data: {} }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user