Merge pull request #544 from ONLYOFFICE/feature/auto-conversion-error

Feature/auto conversion error
This commit is contained in:
Sergey Linnik
2024-03-20 10:02:53 +03:00
committed by GitHub
39 changed files with 516 additions and 51 deletions

View File

@ -78,6 +78,7 @@ def processError(error):
prefix = 'Error occurred in the ConvertService: '
mapping = {
'-9': f'{prefix}Error conversion output format',
'-8': f'{prefix}Error document VKey',
'-7': f'{prefix}Error document request',
'-6': f'{prefix}Error database',

View File

@ -75,13 +75,16 @@ def convert(request):
lang = request.COOKIES.get('ulang') if request.COOKIES.get('ulang') else 'en'
fileUri = docManager.getDownloadUrl(filename, request)
fileExt = fileUtils.getFileExt(filename)
newExt = 'ooxml' # convert to .ooxml
# get an auto-conversion extension from the request body or set it to the ooxml extension
conversionExtension = body.get('fileExt') or 'ooxml'
if docManager.isCanConvert(fileExt): # check if the file extension is available for converting
key = docManager.generateFileKey(filename, request) # generate the file key
# get the url of the converted file
convertedData = serviceConverter.getConvertedData(fileUri, fileExt, newExt, key, True, filePass, lang)
convertedData = serviceConverter.getConvertedData(
fileUri, fileExt, conversionExtension, key, True, filePass, lang
)
# if the converter url is not received, the original file name is passed to the response
if not convertedData: