Skip to content

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

feat: add video support

Marc Seitz76a7cd368ba0
diff --git a/components/document-upload.tsx b/components/document-upload.tsx
index 1e2c064b..49b8179d 100644
--- a/components/document-upload.tsx
+++ b/components/document-upload.tsx
@@ -18,6 +18,11 @@ const fileSizeLimits: { [key: string]: number } = {
"image/png": 100, // 100 MB
"image/jpeg": 100, // 100 MB
"image/jpg": 100, // 100 MB
+ "video/mp4": 500, // 500 MB
+ "video/quicktime": 500, // 500 MB
+ "video/x-msvideo": 500, // 500 MB
+ "video/webm": 500, // 500 MB
+ "video/ogg": 500, // 500 MB
};
export default function DocumentUpload({
@@ -73,17 +78,21 @@ export default function DocumentUpload({
"image/jpg": [], // ".jpg"
"application/zip": [], // ".zip"
"application/x-zip-compressed": [], // ".zip"
+ "video/mp4": [], // ".mp4"
+ "video/quicktime": [], // ".mov"
+ "video/x-msvideo": [], // ".avi"
+ "video/webm": [], // ".webm"
+ "video/ogg": [], // ".ogg"
},
multiple: false,
- maxSize: maxSize * 1024 * 1024, // 30 MB
onDropAccepted: (acceptedFiles) => {
const file = acceptedFiles[0];
const fileType = file.type;
- const fileSizeLimit = fileSizeLimits[fileType] * 1024 * 1024;
+ const fileSizeLimit = (fileSizeLimits[fileType] || maxSize) * 1024 * 1024;
if (file.size > fileSizeLimit) {
toast.error(
- `File size too big for ${fileType} (max. ${fileSizeLimits[fileType]} MB)`,
+ `File size too big for ${fileType} (max. ${fileSizeLimits[fileType] || maxSize} MB)`,
);
return;
}
diff --git a/components/shared/icons/files/video.tsx b/components/shared/icons/files/video.tsx
new file mode 100644
index 00000000..5af93eae
--- /dev/null
+++ b/components/shared/icons/files/video.tsx
@@ -0,0 +1,56 @@
+export default function VideoIcon({
+ className,
+ isLight = true,
+}: {
+ className?: string;
+ isLight?: boolean;
+}) {
+ return (
+ <svg
+ width="576"
+ height="576"
+ viewBox="0 0 576 576"
+ fill="none"
+ className={className}
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <g clipPath="url(#clip0_159_5)">
+ <rect
+ x="57"
+ y="59"
+ width="454"
+ height="462"
+ fill={isLight ? "#000" : "#fff"}
+ />
+ <path
+ opacity="0.999"
+ fillRule="evenodd"
+ clipRule="evenodd"
+ d="M497.5 31.5H77.5C53.1667 37.8333 37.8333 53.1667 31.5 77.5V497.5C37.8333 521.833 53.1667 537.167 77.5 543.5H497.5C521.833 537.167 537.167 521.833 543.5 497.5V77.5C537.167 53.1667 521.833 37.8333 497.5 31.5ZM203.514 117.453C198.584 114.354 192.359 114.179 187.261 116.996C182.164 119.813 179 125.176 179 131V444C179 449.824 182.164 455.187 187.261 458.004C192.359 460.821 198.584 460.646 203.514 457.547L452.514 301.047C457.173 298.119 460 293.002 460 287.5C460 281.998 457.173 276.881 452.514 273.953L203.514 117.453ZM413.933 287.5L211 415.046V159.954L413.933 287.5Z"
+ fill={isLight ? "#fff" : "#111827"}
+ />
+ </g>
+ <rect
+ x="16"
+ y="16"
+ width="544"
+ height="544"
+ rx="48"
+ stroke={isLight ? "#000" : "#fff"}
+ strokeWidth="32"
+ />
+ <defs>
+ <clipPath id="clip0_159_5">
+ <rect
+ x="32"
+ y="32"
+ width="512"
+ height="512"
+ rx="32"
+ fill={isLight ? "#fff" : "#111827"}
+ />
+ </clipPath>
+ </defs>
+ </svg>
+ );
+}
diff --git a/components/upload-zone.tsx b/components/upload-zone.tsx
index 3ca85ae4..c46ec208 100644
--- a/components/upload-zone.tsx
+++ b/components/upload-zone.tsx
@@ -54,6 +54,11 @@ const allAcceptableDropZoneMimeTypes = {
"image/jpg": [], // ".jpg"
"application/zip": [], // ".zip"
"application/x-zip-compressed": [], // ".zip"
+ "video/mp4": [], // ".mp4"
+ "video/webm": [], // ".webm"
+ "video/quicktime": [], // ".mov"
+ "video/x-msvideo": [], // ".avi"
+ "video/ogg": [], // ".ogg"
};
interface FileWithPaths extends File {
@@ -68,6 +73,11 @@ const fileSizeLimits: { [key: string]: number } = {
"image/png": 100, // 100 MB
"image/jpeg": 100, // 100 MB
"image/jpg": 100, // 100 MB
+ "video/mp4": 500, // 500 MB
+ "video/quicktime": 500, // 500 MB
+ "video/x-msvideo": 500, // 500 MB
+ "video/webm": 500, // 500 MB
+ "video/ogg": 500, // 500 MB
};
export default function UploadZone({
diff --git a/lib/constants.ts b/lib/constants.ts
index 26566338..e82b672b 100644
--- a/lib/constants.ts
+++ b/lib/constants.ts
@@ -80,6 +80,11 @@ export const SUPPORTED_DOCUMENT_MIME_TYPES = [
"image/jpg", // .jpg
"application/zip", // .zip
"application/x-zip-compressed", // .zip
+ "video/mp4", // .mp4
+ "video/quicktime", // .mov
+ "video/x-msvideo", // .avi
+ "video/webm", // .webm
+ "video/ogg", // .ogg
];
export const SUPPORTED_DOCUMENT_SIMPLE_TYPES = [
@@ -91,7 +96,8 @@ export const SUPPORTED_DOCUMENT_SIMPLE_TYPES = [
"cad",
"image",
"zip",
-];
+ "video",
+] as const;
export const COUNTRIES: { [key: string]: string } = {
AF: "Afghanistan",
diff --git a/lib/files/put-file-server.ts b/lib/files/put-file-server.ts
index 76f7a194..5c8653f6 100644
--- a/lib/files/put-file-server.ts
+++ b/lib/files/put-file-server.ts
@@ -80,7 +80,7 @@ const putFileInS3Server = async ({
file.type !== "image/jpeg" &&
file.type !== "application/pdf"
) {
- throw new Error("Only PNG, JPEG or PDF files are supported");
+ throw new Error("Only PNG, JPEG, PDF or MP4 files are supported");
}
if (!restricted && !SUPPORTED_DOCUMENT_MIME_TYPES.includes(file.type)) {
diff --git a/lib/utils/get-content-type.ts b/lib/utils/get-content-type.ts
index f0484e0d..52072656 100644
--- a/lib/utils/get-content-type.ts
+++ b/lib/utils/get-content-type.ts
@@ -26,6 +26,12 @@ export function getSupportedContentType(contentType: string): string | null {
case "application/zip":
case "application/x-zip-compressed":
return "zip";
+ case "video/mp4":
+ case "video/quicktime":
+ case "video/x-msvideo":
+ case "video/webm":
+ case "video/ogg":
+ return "video";
default:
return null;
}
@@ -69,6 +75,16 @@ export function getExtensionFromContentType(
return "jpeg";
case "image/jpg":
return "jpg";
+ case "video/mp4":
+ return "mp4";
+ case "video/quicktime":
+ return "mov";
+ case "video/x-msvideo":
+ return "avi";
+ case "video/webm":
+ return "webm";
+ case "video/ogg":
+ return "ogg";
default:
return null;
}
diff --git a/lib/utils/get-file-icon.tsx b/lib/utils/get-file-icon.tsx
index acaa9db9..d605cbff 100644
--- a/lib/utils/get-file-icon.tsx
+++ b/lib/utils/get-file-icon.tsx
@@ -7,6 +7,7 @@ import NotionIcon from "@/components/shared/icons/files/notion";
import PdfIcon from "@/components/shared/icons/files/pdf";
import SheetIcon from "@/components/shared/icons/files/sheet";
import SlidesIcon from "@/components/shared/icons/files/slides";
+import VideoIcon from "@/components/shared/icons/files/video";
export function fileIcon({
fileType,
@@ -48,6 +49,13 @@ export function fileIcon({
case "image/vnd.dxf":
case "cad":
return <CadIcon className={className} isLight={isLight} />;
+ case "video/mp4":
+ case "video/quicktime":
+ case "video/webm":
+ case "video/ogg":
+ case "video/x-msvideo":
+ case "video":
+ return <VideoIcon className={className} isLight={isLight} />;
default:
return <FileIcon className={className} />;
}