added dynamic mime type

This commit is contained in:
root 2023-07-31 22:31:14 +00:00
parent 3cc9626b5f
commit f694ab6a68
3 changed files with 4 additions and 1 deletions

View File

@ -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();
})

1
package-lock.json generated
View File

@ -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"
}
},

View File

@ -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"
}
}