-
Notifications
You must be signed in to change notification settings - Fork 0
/
CrashController.js
42 lines (38 loc) · 1.05 KB
/
CrashController.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* @Author: yaohengfeng [email protected]
* @Date: 2023-04-12 10:09:21
* @LastEditors: yaohengfeng [email protected]
* @LastEditTime: 2023-04-12 10:24:00
* @FilePath: \crash-report\CrashController.js
* @Description: CashController.js
*/
// fs
const { renameSync, copyFileSync } = require('fs');
// path
const { resolve } = require('path');
/**
* crash controller
*/
module.exports = (app) => {
// crash
app.post("/crash", async (req, res) => {
try {
// fields
const fields = req.body.fields;
// console.info("接收请求:", req.query);
console.log('fields: ', fields);
// file info
const fileInfo = req.body.files.upload_file_minidump;
const tmpPath = fileInfo.filepath;
console.info("tmpPath: ", tmpPath);
const destPath = resolve(__dirname, 'report', fileInfo.originalFilename);
console.info("destPath: ", destPath);
copyFileSync(tmpPath, destPath);
// return
res.send('crash success');
} catch (e) {
console.log(e);
res.send('crash failed');
}
});
};