mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-02-10 18:05:10 +08:00
fix(python): correct download name of converted file. Fix Bug 73522
This commit is contained in:
@ -79,7 +79,7 @@ func (srv *DefaultServerEndpointsHandler) Convert(w http.ResponseWriter, r *http
|
||||
return
|
||||
}
|
||||
|
||||
newUrl, newExt, err := srv.ConversionManager.GetConverterUri(fileUrl, fileExt, toExt, key, true)
|
||||
newUrl, newExt, err := srv.ConversionManager.GetConverterUri(fileUrl, fileExt, toExt, key, true, filename)
|
||||
if err != nil {
|
||||
response.Error = err.Error()
|
||||
srv.logger.Errorf("File conversion error: %s", err.Error())
|
||||
|
||||
@ -77,7 +77,7 @@ type ConversionManager interface {
|
||||
GetInternalExtension(fileType string) string
|
||||
IsCanConvert(ext string) bool
|
||||
IsCanFill(ext string) bool
|
||||
GetConverterUri(docUri, fromExt, toExt, docKey string, isAsync bool) (string, string, error)
|
||||
GetConverterUri(docUri, fromExt, toExt, docKey string, isAsync bool, title string) (string, string, error)
|
||||
}
|
||||
|
||||
type CommandManager interface {
|
||||
|
||||
@ -99,6 +99,7 @@ func (cm DefaultConversionManager) GetConverterUri(
|
||||
toExt string,
|
||||
docKey string,
|
||||
isAsync bool,
|
||||
title string,
|
||||
) (string, string, error) {
|
||||
if fromExt == "" {
|
||||
fromExt = utils.GetFileExt(docUri, true)
|
||||
@ -108,7 +109,7 @@ func (cm DefaultConversionManager) GetConverterUri(
|
||||
DocUrl: docUri,
|
||||
OutputType: strings.ReplaceAll(toExt, ".", ""),
|
||||
FileType: fromExt,
|
||||
Title: utils.GetFileName(docUri),
|
||||
Title: title,
|
||||
Key: docKey,
|
||||
Async: isAsync,
|
||||
StandardClaims: jwt.StandardClaims{
|
||||
|
||||
@ -408,8 +408,7 @@ if (typeof jQuery !== "undefined") {
|
||||
jq("#beginViewConverted").removeClass("disable");
|
||||
jq("#downloadConverted").attr("data","fromStorage");
|
||||
} else {
|
||||
jq("#hiddenFileName").attr("data",response.filename.split("&filename=download%3FfileName%3D")
|
||||
.join("&filename="));
|
||||
jq("#hiddenFileName").attr("data",response.filename);
|
||||
jq("#downloadConverted").attr("data","fromConverter");
|
||||
}
|
||||
jq("td[name='convertingTypeButton']").removeClass("disable orange");
|
||||
|
||||
@ -25,11 +25,11 @@ config_manager = ConfigurationManager()
|
||||
|
||||
|
||||
# convert file and give url to a new file
|
||||
def getConvertedData(docUri, fromExt, toExt, docKey, isAsync, filePass=None, lang=None):
|
||||
def getConvertedData(docUri, fromExt, toExt, docKey, isAsync, filePass=None, lang=None, title=None):
|
||||
if not fromExt: # check if the extension from the request matches the real file extension
|
||||
fromExt = fileUtils.getFileExt(docUri) # if not, overwrite the extension value
|
||||
|
||||
title = fileUtils.getFileName(docUri)
|
||||
title = title or fileUtils.getFileName(docUri)
|
||||
|
||||
payload = { # write all the necessary data to the payload object
|
||||
'url': docUri,
|
||||
|
||||
@ -86,7 +86,7 @@ def convert(request):
|
||||
|
||||
# get the url of the converted file
|
||||
convertedData = serviceConverter.getConvertedData(
|
||||
fileUri, fileExt, conversionExtension, key, True, filePass, lang
|
||||
fileUri, fileExt, conversionExtension, key, True, filePass, lang, filename
|
||||
)
|
||||
|
||||
# if the converter url is not received, the original file name is passed to the response
|
||||
|
||||
@ -420,8 +420,7 @@ if (typeof jQuery !== "undefined") {
|
||||
jq("#beginViewConverted").removeClass("disable");
|
||||
jq("#downloadConverted").attr("data","fromStorage");
|
||||
} else {
|
||||
let newFilename = fileName.split('.').slice(0,-1).join('.')
|
||||
jq("#hiddenFileName").attr("data",response.filename.split("&filename=download").join(`&filename=${newFilename}`));
|
||||
jq("#hiddenFileName").attr("data",response.filename);
|
||||
jq("#downloadConverted").attr("data","fromConverter");
|
||||
}
|
||||
jq("td[name='convertingTypeButton']").removeClass("disable orange");
|
||||
|
||||
Reference in New Issue
Block a user