Update index.js
Browse files
index.js
CHANGED
@@ -92,11 +92,11 @@ app.post('/upload', upload.single('file'), async (req, res) => {
|
|
92 |
ctx.fillText(text.trim(), 10, 100);
|
93 |
const rawImageData = canvas.toBuffer('image/jpeg', { quality: 0.75 });
|
94 |
const finalBuffer = Buffer.concat([rawImageData, zipBuffer]);
|
95 |
-
|
96 |
|
97 |
// 生成随机的哈希值作为文件名
|
98 |
-
const hash = crypto.randomBytes(16).toString('hex');
|
99 |
-
const outputFileName = encodeURIComponent(hash + '-pic.zip.jpg');
|
100 |
|
101 |
res.setHeader('Content-Type', 'image/jpeg');
|
102 |
res.setHeader('Content-Disposition', `attachment; filename="${outputFileName}"`);
|
|
|
92 |
ctx.fillText(text.trim(), 10, 100);
|
93 |
const rawImageData = canvas.toBuffer('image/jpeg', { quality: 0.75 });
|
94 |
const finalBuffer = Buffer.concat([rawImageData, zipBuffer]);
|
95 |
+
const outputFileName = encodeURIComponent(fileName.replace(/\.[^/.]+$/, "") + '-pic.zip.jpg');
|
96 |
|
97 |
// 生成随机的哈希值作为文件名
|
98 |
+
//const hash = crypto.randomBytes(16).toString('hex');
|
99 |
+
//const outputFileName = encodeURIComponent(hash + '-pic.zip.jpg');
|
100 |
|
101 |
res.setHeader('Content-Type', 'image/jpeg');
|
102 |
res.setHeader('Content-Disposition', `attachment; filename="${outputFileName}"`);
|