fixes and improvements
This commit is contained in:
+1
-1
@@ -47,7 +47,7 @@ export default function App({
|
||||
reverseOrder={false}
|
||||
toastOptions={{
|
||||
className:
|
||||
"border border-sky-100 dark:border-neutral-700 dark:bg-neutral-900 dark:text-white",
|
||||
"border border-sky-100 dark:border-neutral-700 dark:bg-neutral-800 dark:text-white",
|
||||
}}
|
||||
/>
|
||||
<Component {...pageProps} />
|
||||
|
||||
@@ -89,8 +89,6 @@ export default async function Index(req: NextApiRequest, res: NextApiResponse) {
|
||||
});
|
||||
|
||||
form.parse(req, async (err, fields, files) => {
|
||||
console.log(files);
|
||||
|
||||
const allowedMIMETypes = [
|
||||
"application/pdf",
|
||||
"image/png",
|
||||
@@ -109,17 +107,31 @@ export default async function Index(req: NextApiRequest, res: NextApiResponse) {
|
||||
response: `Sorry, we couldn't process your file. Please ensure it's a PDF, PNG, or JPG format and doesn't exceed ${MAX_UPLOAD_SIZE}MB.`,
|
||||
});
|
||||
} else {
|
||||
console.log(files.file[0].mimetype);
|
||||
|
||||
const fileBuffer = fs.readFileSync(files.file[0].filepath);
|
||||
|
||||
console.log(fileBuffer);
|
||||
|
||||
await createFile({
|
||||
filePath: `archives/${collectionPermissions?.id}/${linkId + suffix}`,
|
||||
data: fileBuffer,
|
||||
const linkStillExists = await prisma.link.findUnique({
|
||||
where: { id: linkId },
|
||||
});
|
||||
|
||||
if (linkStillExists) {
|
||||
await createFile({
|
||||
filePath: `archives/${collectionPermissions?.id}/${
|
||||
linkId + suffix
|
||||
}`,
|
||||
data: fileBuffer,
|
||||
});
|
||||
|
||||
await prisma.link.update({
|
||||
where: { id: linkId },
|
||||
data: {
|
||||
screenshotPath: `archives/${collectionPermissions?.id}/${
|
||||
linkId + suffix
|
||||
}`,
|
||||
lastPreserved: new Date().toISOString(),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
fs.unlinkSync(files.file[0].filepath);
|
||||
}
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ export default function Index() {
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
<p className="text-neutral text-xs">
|
||||
<p className="text-neutral text-sm font-semibold">
|
||||
By {collectionOwner.name}
|
||||
{activeCollection.members.length > 0
|
||||
? ` and ${activeCollection.members.length} others`
|
||||
|
||||
@@ -169,7 +169,7 @@ export default function PublicCollections() {
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<p className="text-neutral text-xs">
|
||||
<p className="text-neutral text-sm font-semibold">
|
||||
By {collectionOwner.name}
|
||||
{collection.members.length > 0
|
||||
? ` and ${collection.members.length} others`
|
||||
|
||||
Reference in New Issue
Block a user