diff --git a/src/components/pages/Files/FilePagation.tsx b/src/components/pages/Files/FilePagation.tsx index eff51f0..ae03758 100644 --- a/src/components/pages/Files/FilePagation.tsx +++ b/src/components/pages/Files/FilePagation.tsx @@ -1,4 +1,4 @@ -import { Box, Center, Checkbox, Group, Pagination, SimpleGrid, Skeleton, Title } from '@mantine/core'; +import { Box, Button, Center, Checkbox, Group, Pagination, SimpleGrid, Skeleton, Title } from '@mantine/core'; import File from 'components/File'; import { FileIcon } from 'components/icons'; import MutedText from 'components/MutedText'; @@ -13,7 +13,7 @@ export default function FilePagation({ disableMediaPreview, exifEnabled }) { if (pages.isSuccess && pages.data.length === 0) { return ( -
+
@@ -23,6 +23,14 @@ export default function FilePagation({ disableMediaPreview, exifEnabled }) { Upload some files and they will show up here.
+
); } diff --git a/src/pages/api/upload.ts b/src/pages/api/upload.ts index b57486b..31f3ad8 100644 --- a/src/pages/api/upload.ts +++ b/src/pages/api/upload.ts @@ -116,7 +116,7 @@ async function handler(req: NextApiReq, res: NextApiRes) { chunks.set(buffer, chunkData.start); } - const ext = filename.split('.').pop(); + const ext = filename.split('.').length === 1 ? '' : filename.split('.').pop(); if (zconfig.uploader.disabled_extensions.includes(ext)) return res.error('disabled extension recieved: ' + ext); let fileName: string; @@ -149,7 +149,7 @@ async function handler(req: NextApiReq, res: NextApiRes) { const file = await prisma.image.create({ data: { - file: `${fileName}.${compressionUsed ? 'jpg' : ext}`, + file: `${fileName}${compressionUsed ? '.jpg' : ext ?? ''}`, mimetype, userId: user.id, embed: !!req.headers.embed, @@ -241,7 +241,7 @@ async function handler(req: NextApiReq, res: NextApiRes) { return res.badRequest(`file[${i}]: size too big`); if (!file.originalname) return res.badRequest(`file[${i}]: no filename`); - const ext = file.originalname.split('.').pop(); + const ext = file.originalname.split('.').length === 1 ? '' : file.originalname.split('.').pop(); if (zconfig.uploader.disabled_extensions.includes(ext)) return res.badRequest(`file[${i}]: disabled extension recieved: ${ext}`); let fileName: string; @@ -273,7 +273,7 @@ async function handler(req: NextApiReq, res: NextApiRes) { let invis: InvisibleImage; const image = await prisma.image.create({ data: { - file: `${fileName}.${compressionUsed ? 'jpg' : ext}`, + file: `${fileName}${compressionUsed ? '.jpg' : ext ?? ''}`, mimetype: req.headers.uploadtext ? 'text/plain' : compressionUsed ? 'image/jpeg' : file.mimetype, userId: user.id, embed: !!req.headers.embed,