| 199 | } |
| 200 | |
| 201 | fn detect_mime(path: &Path) -> String { |
| 202 | let ext = path |
| 203 | .extension() |
| 204 | .and_then(|e| e.to_str()) |
| 205 | .map(|e| e.to_lowercase()) |
| 206 | .unwrap_or_default(); |
| 207 | |
| 208 | match ext.as_str() { |
| 209 | "png" => "image/png", |
| 210 | "jpg" | "jpeg" => "image/jpeg", |
| 211 | "gif" => "image/gif", |
| 212 | "webp" => "image/webp", |
| 213 | "bmp" => "image/bmp", |
| 214 | "ico" => "image/x-icon", |
| 215 | "tiff" | "tif" => "image/tiff", |
| 216 | "avif" => "image/avif", |
| 217 | "heic" | "heif" => "image/heic", |
| 218 | "pdf" => "application/pdf", |
| 219 | "json" => "application/json", |
| 220 | "html" | "htm" => "text/html", |
| 221 | "css" => "text/css", |
| 222 | "js" => "application/javascript", |
| 223 | "ts" => "application/typescript", |
| 224 | "md" => "text/markdown", |
| 225 | "txt" => "text/plain", |
| 226 | "xml" => "application/xml", |
| 227 | "svg" => "image/svg+xml", |
| 228 | _ => "application/octet-stream", |
| 229 | } |
| 230 | .to_string() |
| 231 | } |
| 232 | |
| 233 | fn is_image_mime(mime: &str) -> bool { |
| 234 | mime.starts_with("image/") && mime != "image/svg+xml" && mime != "image/vnd.fastbidsheet" |