diff --git a/meshchat b/meshchat index 9a3c507..8fbdd54 100755 --- a/meshchat +++ b/meshchat @@ -538,8 +538,36 @@ 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 == "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" + end + + print("Content-Type: " .. content_type .. "\r") print("\r") if f then diff --git a/www/files.js b/www/files.js index f758aa5..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) + '';