diff options
| author | Zephyrrus <[email protected]> | 2021-01-06 23:31:10 +0200 |
|---|---|---|
| committer | Zephyrrus <[email protected]> | 2021-01-07 10:47:16 +0200 |
| commit | e0801f0c195baf677247193c274426b2483eafb1 (patch) | |
| tree | 591ef59ae19a274562701562184667281466dce3 /src/api/routes/uploads/uploadPOST.js | |
| parent | chore: Move statistics related functions to it's own file (diff) | |
| download | host.fuwn.me-e0801f0c195baf677247193c274426b2483eafb1.tar.xz host.fuwn.me-e0801f0c195baf677247193c274426b2483eafb1.zip | |
fix: use PassThrough from FileType to get the real mimetype of a file while it's being saved to the disk
Diffstat (limited to 'src/api/routes/uploads/uploadPOST.js')
| -rw-r--r-- | src/api/routes/uploads/uploadPOST.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/api/routes/uploads/uploadPOST.js b/src/api/routes/uploads/uploadPOST.js index 8e26079..a0dba27 100644 --- a/src/api/routes/uploads/uploadPOST.js +++ b/src/api/routes/uploads/uploadPOST.js @@ -160,7 +160,7 @@ const uploadFile = async (req, res) => { const infoMap = req.files.map(file => ({ path: path.join(uploadDir, file.filename), - data: file + data: { ...file, mimetype: Util.getMimeFromType(file.fileType) || file.mimetype || '' } })); return infoMap[0]; @@ -189,6 +189,8 @@ const finishChunks = async req => { */ file.extname = typeof file.original === 'string' ? Util.getExtension(file.original) : ''; + file.fileType = chunksData[file.uuid].fileType; + file.mimetype = Util.getMimeFromType(chunksData[file.uuid].fileType) || file.mimetype || ''; if (Util.isExtensionBlocked(file.extname)) { throw `${file.extname ? `${file.extname.substr(1).toUpperCase()} files` : 'Files with no extension'} are not permitted.`; // eslint-disable-line no-throw-literal @@ -218,7 +220,7 @@ const finishChunks = async req => { filename: name, originalname: file.original || '', extname: file.extname, - mimetype: file.type || '', + mimetype: file.mimetype, size: file.size, hash }; |