Skip to content

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

feat: add .rar and other compressed content types

Marc Seitzaaaa958377ca
diff --git a/lib/constants.ts b/lib/constants.ts
index 8a4a2af4..71ad42b2 100644
--- a/lib/constants.ts
+++ b/lib/constants.ts
@@ -103,6 +103,12 @@ export const SUPPORTED_DOCUMENT_MIME_TYPES = [
"image/jpg", // .jpg
"application/zip", // .zip
"application/x-zip-compressed", // .zip
+ "application/vnd.rar", // .rar
+ "application/x-rar-compressed", // .rar (older MIME type)
+ "application/x-tar", // .tar
+ "application/gzip", // .gz, .tar.gz, .tgz
+ "application/x-gzip", // .gz, .tar.gz, .tgz (older MIME type)
+ "application/x-compressed-tar", // .tar.gz, .tgz (custom - sometimes returned by browsers)
"video/mp4", // .mp4
"video/quicktime", // .mov
"video/x-msvideo", // .avi
@@ -168,6 +174,12 @@ export const FULL_PLAN_ACCEPTED_FILE_TYPES = {
"image/jpg": [], // ".jpg"
"application/zip": [], // ".zip"
"application/x-zip-compressed": [], // ".zip"
+ "application/vnd.rar": [".rar"], // ".rar"
+ "application/x-rar-compressed": [".rar"], // ".rar"
+ "application/x-tar": [".tar"], // ".tar"
+ "application/gzip": [".gz", ".tar.gz", ".tgz"], // ".gz", ".tar.gz", ".tgz"
+ "application/x-gzip": [".gz", ".tar.gz", ".tgz"], // ".gz", ".tar.gz", ".tgz"
+ "application/x-compressed-tar": [".tar.gz", ".tgz"], // ".tar.gz", ".tgz"
"video/mp4": [".mp4"], // ".mp4"
"video/quicktime": [".mov"], // ".mov"
"video/x-msvideo": [".avi"], // ".avi"
@@ -219,6 +231,12 @@ export const VIEWER_ACCEPTED_FILE_TYPES = {
"image/jpg": [], // ".jpg"
"application/zip": [".zip"], // ".zip"
"application/x-zip-compressed": [".zip"], // ".zip"
+ "application/vnd.rar": [".rar"], // ".rar"
+ "application/x-rar-compressed": [".rar"], // ".rar"
+ "application/x-tar": [".tar"], // ".tar"
+ "application/gzip": [".gz", ".tar.gz", ".tgz"], // ".gz", ".tar.gz", ".tgz"
+ "application/x-gzip": [".gz", ".tar.gz", ".tgz"], // ".gz", ".tar.gz", ".tgz"
+ "application/x-compressed-tar": [".tar.gz", ".tgz"], // ".tar.gz", ".tgz"
"application/vnd.ms-outlook": [".msg"], // ".msg"
"message/rfc822": [".eml"], // ".eml"
};
diff --git a/lib/files/put-file.ts b/lib/files/put-file.ts
index 9dfbce23..ef63fb51 100644
--- a/lib/files/put-file.ts
+++ b/lib/files/put-file.ts
@@ -113,6 +113,11 @@ const putFileInS3 = async ({
".sbx",
".qix",
".cpg",
+ ".rar",
+ ".tar",
+ ".tar.gz",
+ ".tgz",
+ ".gz",
];
const lowerName = file.name.toLowerCase();
if (
diff --git a/lib/utils/get-content-type.ts b/lib/utils/get-content-type.ts
index 04da71c2..c32407c7 100644
--- a/lib/utils/get-content-type.ts
+++ b/lib/utils/get-content-type.ts
@@ -32,6 +32,12 @@ export function getSupportedContentType(contentType: string): string | null {
return "image";
case "application/zip":
case "application/x-zip-compressed":
+ case "application/vnd.rar":
+ case "application/x-rar-compressed":
+ case "application/x-tar":
+ case "application/gzip":
+ case "application/x-gzip":
+ case "application/x-compressed-tar":
return "zip";
case "video/mp4":
case "video/quicktime":
@@ -159,6 +165,19 @@ export function getExtensionFromContentType(
return "sbx";
case "application/x-mapserver-qix":
return "qix";
+ case "application/zip":
+ case "application/x-zip-compressed":
+ return "zip";
+ case "application/vnd.rar":
+ case "application/x-rar-compressed":
+ return "rar";
+ case "application/x-tar":
+ return "tar";
+ case "application/gzip":
+ case "application/x-gzip":
+ return "gz";
+ case "application/x-compressed-tar":
+ return "tar.gz";
default:
return null;
}