Skip to content

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

feat: add page number limit

Marc Seitz974a95014349
diff --git a/components/document-upload.tsx b/components/document-upload.tsx
index 6f212d87..91b1354f 100644
--- a/components/document-upload.tsx
+++ b/components/document-upload.tsx
@@ -55,6 +55,8 @@ export default function DocumentUpload({
}) {
const { plan, loading } = usePlan();
const maxSize = plan === "business" || plan === "datarooms" ? 100 : 30;
+ const maxNumPages = plan === "business" || plan === "datarooms" ? 500 : 100;
+
const { getRootProps, getInputProps } = useDropzone({
accept: {
"application/pdf": [], // ".pdf"
@@ -85,8 +87,8 @@ export default function DocumentUpload({
.arrayBuffer()
.then((buffer) => {
getPagesCount(buffer).then((numPages) => {
- if (numPages > 500) {
- toast.error("File has too many pages (max. 100)");
+ if (numPages > maxNumPages) {
+ toast.error(`File has too many pages (max. ${maxNumPages})`);
} else {
setCurrentFile(file);
}
diff --git a/components/upload-zone.tsx b/components/upload-zone.tsx
index 61cb4bc0..93d96ad8 100644
--- a/components/upload-zone.tsx
+++ b/components/upload-zone.tsx
@@ -97,6 +97,7 @@ export default function UploadZone({
const teamInfo = useTeam();
const { data: session } = useSession();
const maxSize = plan === "business" || plan === "datarooms" ? 250 : 30;
+ const maxNumPages = plan === "business" || plan === "datarooms" ? 500 : 100;
const [progress, setProgress] = useState<number>(0);
const [showProgress, setShowProgress] = useState(false);
@@ -117,7 +118,7 @@ export default function UploadZone({
const buffer = await file.arrayBuffer();
numPages = await getPagesCount(buffer);
- if (numPages > 500) {
+ if (numPages > maxNumPages) {
setUploads((prev) =>
prev.filter((upload) => upload.fileName !== file.name),
);
@@ -125,7 +126,7 @@ export default function UploadZone({
return setRejectedFiles((prev) => [
{
fileName: file.name,
- message: "File has too many pages (max. 100)",
+ message: `File has too many pages (max. ${maxNumPages})`,
},
...prev,
]);