fix: logic download in image detail
This commit is contained in:
parent
d471035246
commit
d9475cc0a9
|
|
@ -272,6 +272,47 @@ const DetailImage = (data: any) => {
|
||||||
// }
|
// }
|
||||||
// };
|
// };
|
||||||
|
|
||||||
|
// const handleDownload = () => {
|
||||||
|
// if (downloadProgress !== 0) return;
|
||||||
|
|
||||||
|
// if (!imageSizeSelected) {
|
||||||
|
// alert("Please select an image size before downloading.");
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (!userId) {
|
||||||
|
// router.push("/auth");
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// sendActivityLog(2);
|
||||||
|
// sendActivityLog(3);
|
||||||
|
|
||||||
|
// if (isDownloadAll) {
|
||||||
|
// const baseId = slug.split("-")?.[0];
|
||||||
|
// const url = `${process.env.NEXT_PUBLIC_API}/media/file/download-zip?id=${baseId}&resolution=${imageSizeSelected}`;
|
||||||
|
// downloadFile(url, "FileDownload.zip");
|
||||||
|
// } else {
|
||||||
|
// const selectedFile = detailDataImage?.files?.[selectedImage];
|
||||||
|
|
||||||
|
// if (!selectedFile) {
|
||||||
|
// toast({
|
||||||
|
// description: "Gambar tidak ditemukan.",
|
||||||
|
// variant: "destructive",
|
||||||
|
// });
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (isFromSPIT && main?.url?.includes("spit.humas")) {
|
||||||
|
// // downloadFile(selectedFile.url, selectedFile.names || "image.jpg");
|
||||||
|
// downloadFile(`${main?.url}`, `${main.names}`);
|
||||||
|
// } else {
|
||||||
|
// const url = `${process.env.NEXT_PUBLIC_API}/media/view?id=${selectedFile.id}&operation=file&type=image&resolution=${imageSizeSelected}`;
|
||||||
|
// downloadFile(`${main?.url}`, `${main.names}`);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
|
||||||
const handleDownload = () => {
|
const handleDownload = () => {
|
||||||
if (downloadProgress !== 0) return;
|
if (downloadProgress !== 0) return;
|
||||||
|
|
||||||
|
|
@ -303,12 +344,16 @@ const DetailImage = (data: any) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFromSPIT && main?.url?.includes("spit.humas")) {
|
if (isFromSPIT && selectedFile?.url?.includes("spit.humas")) {
|
||||||
// downloadFile(selectedFile.url, selectedFile.names || "image.jpg");
|
// ambil url asli dari SPIT, tapi nama file dari judul (main.names)
|
||||||
downloadFile(`${main?.url}`, `${main.names}`);
|
downloadFile(
|
||||||
|
selectedFile.url,
|
||||||
|
main?.names || detailDataImage?.title || "image"
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
const url = `${process.env.NEXT_PUBLIC_API}/media/view?id=${selectedFile.id}&operation=file&type=image&resolution=${imageSizeSelected}`;
|
const url = `${process.env.NEXT_PUBLIC_API}/media/view?id=${selectedFile.id}&operation=file&type=image&resolution=${imageSizeSelected}`;
|
||||||
downloadFile(`${main?.url}`, `${main.names}`);
|
// ambil file sesuai yang dipilih, nama tetap dari judul (main.names)
|
||||||
|
downloadFile(url, main?.names || detailDataImage?.title || "image");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue