From 2b97401a5da4b83638c7083c9bd1630e6612022e Mon Sep 17 00:00:00 2001
From: James Alton <167721556+ham-k7dev@users.noreply.github.com>
Date: Fri, 26 Apr 2024 14:57:49 -0600
Subject: [PATCH 1/5] Added common image content types, only attachment for
non-images
---
meshchat | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/meshchat b/meshchat
index 9a3c507..4062128 100755
--- a/meshchat
+++ b/meshchat
@@ -538,8 +538,22 @@ function file_download()
release_lock()
print("Content-MD5: " .. md5 .. "\r")
- print("Content-Disposition: attachment; filename=\"" .. file .. "\";\r")
- print("Content-type: application/octet-stream\r")
+
+ local ext = string.match(file, "%.(%a+)$")
+ local content_type
+
+ if ext == "jpg" or ext == "jpeg" then
+ content_type = "image/jpeg"
+ elseif ext == "png" then
+ content_type = "image/png"
+ elseif ext == "gif" then
+ content_type = "image/gif"
+ else
+ print("Content-Disposition: attachment; filename=\"" .. file .. "\";\r")
+ content_type = "application/octet-stream"
+ end
+
+ print("Content-Type: " .. content_type .. "\r")
print("\r")
if f then
From b9e04fd3b2825fab006f67ca4370c58664eaa342 Mon Sep 17 00:00:00 2001
From: James Alton <167721556+ham-k7dev@users.noreply.github.com>
Date: Fri, 26 Apr 2024 14:59:36 -0600
Subject: [PATCH 2/5] Relative link and images open in new tab
---
www/files.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/www/files.js b/www/files.js
index f758aa5..75373f3 100644
--- a/www/files.js
+++ b/www/files.js
@@ -110,7 +110,7 @@ function load_files() {
port = ':8080'
}
}
- html += '
' + data.files[i].file + ' | ';
+ html += '' + data.files[i].file +
html += ' | ' + numeral(data.files[i].size).format('0.0 b') + ' | ';
html += '' + data.files[i].node + ' | ';
html += '' + format_date(date) + ' | ';
From 009c9b65b76026310ab8b10de948cc664bdbe482 Mon Sep 17 00:00:00 2001
From: James Alton <167721556+ham-k7dev@users.noreply.github.com>
Date: Fri, 26 Apr 2024 15:01:50 -0600
Subject: [PATCH 3/5] Added closing tags
---
www/files.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/www/files.js b/www/files.js
index 75373f3..7ad97c4 100644
--- a/www/files.js
+++ b/www/files.js
@@ -110,7 +110,7 @@ function load_files() {
port = ':8080'
}
}
- html += '' + data.files[i].file +
+ html += ' | ' + data.files[i].file + ' | ';
html += '' + numeral(data.files[i].size).format('0.0 b') + ' | ';
html += '' + data.files[i].node + ' | ';
html += '' + format_date(date) + ' | ';
From 916bb7aacb58351d29fbcfc7ec572371668f72a5 Mon Sep 17 00:00:00 2001
From: James Alton <167721556+ham-k7dev@users.noreply.github.com>
Date: Sun, 28 Apr 2024 12:37:42 -0600
Subject: [PATCH 4/5] Revert relative link
---
www/files.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/www/files.js b/www/files.js
index 7ad97c4..5138d7d 100644
--- a/www/files.js
+++ b/www/files.js
@@ -110,7 +110,7 @@ function load_files() {
port = ':8080'
}
}
- html += '' + data.files[i].file + ' | ';
+ html += '' + data.files[i].file + ' | ';
html += '' + numeral(data.files[i].size).format('0.0 b') + ' | ';
html += '' + data.files[i].node + ' | ';
html += '' + format_date(date) + ' | ';
From de8fd957873545b84c63a56418dd24a13afe0817 Mon Sep 17 00:00:00 2001
From: James Alton <167721556+ham-k7dev@users.noreply.github.com>
Date: Mon, 29 Apr 2024 07:01:16 -0600
Subject: [PATCH 5/5] Added more image extensions/mime types
---
meshchat | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/meshchat b/meshchat
index 4062128..8fbdd54 100755
--- a/meshchat
+++ b/meshchat
@@ -542,12 +542,26 @@ function file_download()
local ext = string.match(file, "%.(%a+)$")
local content_type
- if ext == "jpg" or ext == "jpeg" then
+ if ext == "jpe" or ext == "jpg" or ext == "jpeg" then
content_type = "image/jpeg"
elseif ext == "png" then
content_type = "image/png"
elseif ext == "gif" then
content_type = "image/gif"
+ elseif ext == "webp" then
+ content_type = "image/webp"
+ elseif ext == "bmp" then
+ content_type = "image/bmp"
+ elseif ext == "tiff" or ext == "tif" then
+ content_type = "image/tiff"
+ elseif ext == "ico" then
+ content_type = "image/x-icon"
+ elseif ext == "svg" or ext == "svgz" then
+ content_type = "image/svg+xml"
+ elseif ext == "avif" then
+ content_type = "image/avif"
+ elseif ext == "heic" or ext == "heif" then
+ content_type = "image/heic"
else
print("Content-Disposition: attachment; filename=\"" .. file .. "\";\r")
content_type = "application/octet-stream"