Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

feat: check content type on upload

Marc Seitzedc3ec0f2a11
diff --git a/lib/files/put-file-server.ts b/lib/files/put-file-server.ts
index a26048f9..82798ddf 100644
--- a/lib/files/put-file-server.ts
+++ b/lib/files/put-file-server.ts
@@ -66,6 +66,10 @@ const putFileInS3Server = async ({
docId = newId("doc");
}
+ if (file.type !== "image/png") {
+ throw new Error("Only PNG files are supported");
+ }
+
const client = getS3Client();
// Get the basename and extension for the file
diff --git a/lib/files/put-file.ts b/lib/files/put-file.ts
index 9b054d0f..b90d23ff 100644
--- a/lib/files/put-file.ts
+++ b/lib/files/put-file.ts
@@ -64,6 +64,11 @@ const putFileInS3 = async ({
if (!docId) {
docId = newId("doc");
}
+
+ if (file.type !== "application/pdf") {
+ throw new Error("Only PDF files are supported");
+ }
+
const presignedResponse = await fetch(
`${process.env.NEXT_PUBLIC_BASE_URL}/api/file/s3/get-presigned-post-url`,
{