upd: upload file
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
export async function fileUpload({ file }: { file: File}) {
|
||||
const formData = new FormData();
|
||||
formData.append("file", file);
|
||||
formData.append("dirId", "cm0x8dbwn0005bp5tgmfcthzw");
|
||||
|
||||
try {
|
||||
const res = await fetch("https://wibu-storage.wibudev.com/api/upload", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
headers: {
|
||||
Authorization: `Bearer ${process.env.WS_APIKEY}`
|
||||
}
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
console.log("File uploaded successfullyAmalia");
|
||||
const hasil = await res.text()
|
||||
console.log('berhasilAmalia',hasil)
|
||||
|
||||
} else {
|
||||
const errorText = await res.text();
|
||||
console.log('errorAmalia',errorText)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Upload error:", error);
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ export default function Profile() {
|
||||
const res = await funGetProfileByCookies()
|
||||
setData(res.data)
|
||||
setIMG(`/api/file/img?jenis=image&cat=user&file=${res.data.img}`)
|
||||
// setIMG(`https://wibu-storage.wibudev.com/api/files/view/cm0x8dbwn0005bp5tgmfcthzw/${res.data.img}`)
|
||||
setLoading(false)
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
Reference in New Issue
Block a user