diff --git a/src/pages/files/[fileId].js b/src/pages/files/[fileId].js index 9c98147..3673296 100644 --- a/src/pages/files/[fileId].js +++ b/src/pages/files/[fileId].js @@ -7,8 +7,7 @@ import { getFileInfo } from "src/utils/helpers/fileHelpers"; import { formatBytes } from "src/utils/helpers/stringHelpers"; import { downloadURI } from "src/utils/helpers/webUtils"; -export default function File(props) { - const { isValidFile, fileData } = props; +export default function File({ isValidFile, fileData }) { const file = JSON.parse(fileData); let { uploader, @@ -21,9 +20,46 @@ export default function File(props) { height, ext, size, + isImage, + isVideo, } = file; - const metaData = ; + let imageOrVideo; + if (isValidFile) { + if (isImage) { + imageOrVideo = { + images: [ + { + url: fileUrl, + height: height, + width: width, + }, + ], + }; + } + if (isVideo) { + imageOrVideo = { + videos: [ + { + url: fileUrl, + height: height, + width: width, + }, + ], + }; + } + } + + const metaData = ( + + ); let toShow; if (!isValidFile) { @@ -44,8 +80,7 @@ export default function File(props) { ); } if (isValidFile) { - contentType = contentType.toLowerCase(); - if (contentType.includes("image")) { + if (isImage) { toShow = ( {fileId} ); } - if (contentType.includes("video")) { + if (isVideo) { toShow = ; } }