|
|
|
@ -23,6 +23,8 @@ app.use(cors())
|
|
|
|
|
|
|
|
|
|
//上传并识别功能
|
|
|
|
|
const upload = multer({ dest: 'uploads/' }); // 上传文件的临时存储目录 // Multer是一个Node.js中间件,用于处理multipart/form-data类型的表单数据
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.post('/api/upload', upload.single('image'), function(req, res) {// 单文件上传
|
|
|
|
|
if (!req.file) {
|
|
|
|
|
return res.status(400).send('No file uploaded.');
|
|
|
|
@ -35,6 +37,8 @@ app.post('/api/upload', upload.single('image'), function(req, res) {// 单文件
|
|
|
|
|
console.log(fileHash, 'fileHash')
|
|
|
|
|
const hash = crypto.createHash('sha256');
|
|
|
|
|
const input = fs.createReadStream(tempFilePath);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
input.on('data', (data) => {
|
|
|
|
|
hash.update(data);
|
|
|
|
|