Skip to content

Commit

Permalink
[wopi] Allow any name in convert-to request
Browse files Browse the repository at this point in the history
  • Loading branch information
konovalovsergey committed Oct 7, 2024
1 parent 34c0311 commit bd0a7d2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions DocService/sources/converterservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions DocService/sources/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit bd0a7d2

Please sign in to comment.