From bd0a7d29257c72358e3ab7e3389b7d75764847e8 Mon Sep 17 00:00:00 2001 From: Sergey Konovalov Date: Mon, 7 Oct 2024 19:07:54 +0300 Subject: [PATCH] [wopi] Allow any name in convert-to request --- DocService/sources/converterservice.js | 9 +++++---- DocService/sources/server.js | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/DocService/sources/converterservice.js b/DocService/sources/converterservice.js index af5cddb7..0d9d9eaf 100644 --- a/DocService/sources/converterservice.js +++ b/DocService/sources/converterservice.js @@ -530,9 +530,10 @@ function convertTo(req, res) { return; } let docId, fileTo, status, originalname; - if (req.file && req.file.originalname && req.file.buffer) { - originalname = req.file.originalname; - let filetype = path.extname(req.file.originalname).substring(1); + if (req.files?.length > 0 && req.files[0].originalname && req.files[0].buffer) { + const file = req.files[0]; + originalname = file.originalname; + let filetype = path.extname(file.originalname).substring(1); if (filetype && !constants.EXTENTION_REGEX.test(filetype)) { ctx.logger.warn('convertRequest unexpected filetype = %s', filetype); res.sendStatus(400); @@ -544,7 +545,7 @@ function convertTo(req, res) { ctx.setDocId(docId); //todo stream - let buffer = req.file.buffer; + let buffer = file.buffer; yield storageBase.putObject(ctx, docId + '/origin.' + filetype, buffer, buffer.length); let cmd = new commonDefines.InputCommand(); diff --git a/DocService/sources/server.js b/DocService/sources/server.js index 86bcefae..b3896ccb 100644 --- a/DocService/sources/server.js +++ b/DocService/sources/server.js @@ -280,8 +280,8 @@ docsCoServer.install(server, () => { let fileForms = multer({limits: {fieldSize: cfgDownloadMaxBytes}}); app.get('/hosting/discovery', checkWopiEnable, utils.checkClientIp, wopiClient.discovery); app.get('/hosting/capabilities', checkWopiEnable, utils.checkClientIp, wopiClient.collaboraCapabilities); - app.post('/lool/convert-to/:format?', checkWopiEnable, utils.checkClientIp, urleEcodedParser, fileForms.single('data'), converterService.convertTo); - app.post('/cool/convert-to/:format?', checkWopiEnable, utils.checkClientIp, urleEcodedParser, fileForms.single('data'), converterService.convertTo); + app.post('/lool/convert-to/:format?', checkWopiEnable, utils.checkClientIp, urleEcodedParser, fileForms.any(), converterService.convertTo); + app.post('/cool/convert-to/:format?', checkWopiEnable, utils.checkClientIp, urleEcodedParser, fileForms.any(), converterService.convertTo); app.post('/hosting/wopi/:documentType/:mode', checkWopiEnable, urleEcodedParser, forms.none(), utils.lowercaseQueryString, wopiClient.getEditorHtml); app.post('/hosting/wopi/convert-and-edit/:ext/:targetext', checkWopiEnable, urleEcodedParser, forms.none(), utils.lowercaseQueryString, wopiClient.getConverterHtml); app.get('/hosting/wopi/convert-and-edit-handler', checkWopiEnable, utils.lowercaseQueryString, converterService.getConverterHtmlHandler);