diff --git a/module/cloud.js b/module/cloud.js index 2f80fc8..bb5f157 100644 --- a/module/cloud.js +++ b/module/cloud.js @@ -69,11 +69,7 @@ module.exports = async (query, request) => { } } else { if (!fileMd5) { - fileMd5 = await new Promise((resolve) => { - setImmediate(() => { - resolve(crypto.createHash('md5').update(query.songFile.data).digest('hex')) - }) - }) + fileMd5 = crypto.createHash('md5').update(query.songFile.data).digest('hex') } fileSize = query.songFile.data.byteLength } diff --git a/server.js b/server.js index a02d4d8..1bc6e86 100644 --- a/server.js +++ b/server.js @@ -178,12 +178,15 @@ async function consturctServer(moduleDefs) { /** * Body Parser and File Upload */ - app.use(express.json({ limit: '500mb' })) - app.use(express.urlencoded({ extended: false, limit: '500mb' })) + const MAX_UPLOAD_SIZE_MB = 500 + const MAX_UPLOAD_SIZE_BYTES = MAX_UPLOAD_SIZE_MB * 1024 * 1024 + + app.use(express.json({ limit: `${MAX_UPLOAD_SIZE_MB}mb` })) + app.use(express.urlencoded({ extended: false, limit: `${MAX_UPLOAD_SIZE_MB}mb` })) app.use(fileUpload({ limits: { - fileSize: 500 * 1024 * 1024 + fileSize: MAX_UPLOAD_SIZE_BYTES }, useTempFiles: true, tempFileDir: require('os').tmpdir(),