From f694ab6a68ce6dcc91150eef63333c8a782e633b Mon Sep 17 00:00:00 2001 From: root Date: Mon, 31 Jul 2023 22:31:14 +0000 Subject: [PATCH] added dynamic mime type --- index.mjs | 3 ++- package-lock.json | 1 + package.json | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/index.mjs b/index.mjs index 751b57f..18c9917 100644 --- a/index.mjs +++ b/index.mjs @@ -3,6 +3,7 @@ import * as minio from "minio"; import 'dotenv/config'; import express from "express"; import cors from "cors"; +import mime from "mime-types"; let minioClient = new minio.Client({ @@ -28,7 +29,7 @@ app.get("/img/:bucket/:image_path(*)", async (req, res) => { }) objStream.on('end', function() { res.header("Access-Control-Allow-Origin", "*"); - res.writeHead(200, {'Content-Type': 'image/jpeg'}); + res.writeHead(200, {'Content-Type': mime.lookup(req.params.image_path) }); res.write(data); res.end(); }) diff --git a/package-lock.json b/package-lock.json index 106ce0e..889326a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "cors": "^2.8.5", "dotenv": "^16.3.1", "express": "^4.18.2", + "mime-types": "^2.1.35", "minio": "^7.1.1" } }, diff --git a/package.json b/package.json index 3eac3bb..780881c 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "cors": "^2.8.5", "dotenv": "^16.3.1", "express": "^4.18.2", + "mime-types": "^2.1.35", "minio": "^7.1.1" } }