Merge remote-tracking branch 'remotes/origin/develop' into feature/restore-history

# Conflicts:
#	CHANGELOG.md
This commit is contained in:
Sergey Linnik
2023-10-23 13:40:36 +03:00
22 changed files with 60 additions and 26 deletions

View File

@ -3,10 +3,10 @@ name: Artifact Csharp MVC
on:
workflow_dispatch:
push:
branches: [master, main]
branches: [master]
paths: ['web/documentserver-example/csharp-mvc/**']
pull_request:
branches: [master, main]
branches: [master]
paths: ['web/documentserver-example/csharp-mvc/**']
jobs:

View File

@ -3,10 +3,10 @@ name: Artifact Csharp
on:
workflow_dispatch:
push:
branches: [master, main]
branches: [master]
paths: ['web/documentserver-example/csharp/**']
pull_request:
branches: [master, main, develop]
branches: [master]
paths: ['web/documentserver-example/csharp/**']
jobs:

View File

@ -3,10 +3,10 @@ name: Artifact Java
on:
workflow_dispatch:
push:
branches: [master, main]
branches: [master]
paths: ['web/documentserver-example/java/**']
pull_request:
branches: [master, main]
branches: [master]
paths: ['web/documentserver-example/java/**']
jobs:

View File

@ -3,10 +3,10 @@ name: Artifact Nodejs
on:
workflow_dispatch:
push:
branches: [master, main]
branches: [master]
paths: ['web/documentserver-example/nodejs/**']
pull_request:
branches: [master, main]
branches: [master]
paths: ['web/documentserver-example/nodejs/**']
jobs:

View File

@ -3,10 +3,10 @@ name: Artifact PHP
on:
workflow_dispatch:
push:
branches: [master, main]
branches: [master]
paths: ['web/documentserver-example/php/**']
pull_request:
branches: [master, main]
branches: [master]
paths: ['web/documentserver-example/php/**']
jobs:

View File

@ -3,10 +3,10 @@ name: Artifact Python
on:
workflow_dispatch:
push:
branches: [master, main]
branches: [master]
paths: ['web/documentserver-example/python/**']
pull_request:
branches: [master, main]
branches: [master]
paths: ['web/documentserver-example/python/**']
jobs:

View File

@ -3,10 +3,10 @@ name: Artifact Ruby
on:
workflow_dispatch:
push:
branches: [master, main]
branches: [master]
paths: ['web/documentserver-example/ruby/**']
pull_request:
branches: [master, main]
branches: [master]
paths: ['web/documentserver-example/ruby/**']
jobs:

View File

@ -3,10 +3,10 @@ name: Artifact Java Spring
on:
workflow_dispatch:
push:
branches: [master, main]
branches: [master]
paths: ['web/documentserver-example/java-spring/**']
pull_request:
branches: [master, main]
branches: [master]
paths: ['web/documentserver-example/java-spring/**']
jobs:

View File

@ -3,6 +3,7 @@
- php: getting history via api
- ruby: getting history via api
- python: getting history via api
- trimming long name of uploading file
- nodejs: link in referenceData
- onRequestSelectDocument method
- onRequestSelectSpreadsheet method

View File

@ -177,7 +177,12 @@ namespace OnlineEditorsExampleMVC.Helpers
// get a file name with an index if the file with such a name already exists
public static string GetCorrectName(string fileName, string userAddress = null)
{
int maxName;
int.TryParse(WebConfigurationManager.AppSettings["filename-max"], out maxName);
var baseName = Path.GetFileNameWithoutExtension(fileName);
if (baseName.Length > maxName){
baseName = baseName.Substring(0, maxName) + "[...]";
}
var ext = Path.GetExtension(fileName).ToLower();
var name = baseName + ext;

View File

@ -5,6 +5,7 @@
<add key="filesize-max" value="52428800"/>
<add key="storage-path" value=""/>
<add key="filename-max" value="50"/>
<add key="files.docservice.fillform-docs" value=".docx|.oform"/>
<add key="files.docservice.viewed-docs" value=".djvu|.oxps|.pdf|.xps"/>

View File

@ -538,7 +538,12 @@ namespace OnlineEditorsExample
// get the correct file name if such a name already exists
public static string GetCorrectName(string fileName, string userAddress = null)
{
int maxName;
int.TryParse(WebConfigurationManager.AppSettings["filename-max"], out maxName);
var baseName = Path.GetFileNameWithoutExtension(fileName); // get file name without extension
if (baseName.Length > maxName){
baseName = baseName.Substring(0, maxName) + "[...]";
}
var ext = Path.GetExtension(fileName).ToLower(); // get file extension
var name = baseName + ext; // get full file name

View File

@ -5,6 +5,7 @@
<add key="filesize-max" value="52428800"/>
<add key="storage-path" value=""/>
<add key="filename-max" value="50"/>
<add key="files.docservice.fillform-docs" value=".docx|.oform"/>
<add key="files.docservice.viewed-docs" value=".djvu|.oxps|.pdf|.xps"/>

View File

@ -38,6 +38,8 @@ import static com.onlyoffice.integration.documentserver.util.Constants.MAX_FILE_
public class DefaultFileUtility implements FileUtility {
@Value("${filesize-max}")
private String filesizeMax;
@Value("${filename-max}")
private String filenameMax;
@Autowired
private FormatService formatService;
@ -136,13 +138,18 @@ public class DefaultFileUtility implements FileUtility {
// generate the file path from file directory and name
public Path generateFilepath(final String directory, final String fullFileName) {
String fileName = getFileNameWithoutExtension(fullFileName); // get file name without extension
int maxName = Integer.parseInt(filenameMax);
String fileName = getFileNameWithoutExtension(fullFileName);
if (fileName.length() > maxName) {
fileName = fileName.substring(0, maxName) + "[...]";
}
String fileExtension = getFileExtension(fullFileName); // get file extension
Path path = Paths.get(directory + fullFileName); // get the path to the files with the specified name
// get the path to the files with the specified name
Path path = Paths.get(directory + fileName + "." + fileExtension);
for (int i = 1; Files.exists(path); i++) { // run through all the files with the specified name
// get a name of each file without extension and add an index to it
fileName = getFileNameWithoutExtension(fullFileName) + "(" + i + ")";
fileName = fileName + "(" + i + ")";
// create a new path for this file with the correct name and extension
path = Paths.get(directory + fileName + "." + fileExtension);

View File

@ -4,6 +4,7 @@ server.address=
server.port=4000
filesize-max=5242880
filename-max=50
files.storage=
files.storage.folder=documents

View File

@ -246,7 +246,11 @@ public final class DocumentManager {
// get a file name with an index if the file with such a name already exists
public static String getCorrectName(final String fileName, final String userAddress) {
int maxName = Integer.parseInt(ConfigManager.getProperty("filename-max"));
String baseName = FileUtility.getFileNameWithoutExtension(fileName);
if (baseName.length() > maxName) {
baseName = baseName.substring(0, maxName) + "[...]";
}
String ext = FileUtility.getFileExtension(fileName);
String name = baseName + "." + ext;

View File

@ -2,6 +2,7 @@ version=1.7.0
filesize-max=5242880
storage-folder=app_data
filename-max=50
files.docservice.timeout=120000

View File

@ -25,6 +25,7 @@
"storageFolder": "./files",
"storagePath": "/files",
"maxFileSize": 1073741824,
"maxNameLength": 50,
"mobileRegEx": "android|avantgo|playbook|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino",
"token": {
"enable": false,

View File

@ -84,7 +84,10 @@ DocManager.prototype.getCustomParams = function getCustomParams() {
// get the correct file name if such a name already exists
DocManager.prototype.getCorrectName = function getCorrectName(fileName, userAddress) {
const baseName = fileUtility.getFileName(fileName, true); // get file name from the url without extension
// get file name from the url without extension
const maxName = configServer.get('maxNameLength');
const baseName = fileUtility.getFileName(fileName, true).substr(0, maxName)
+ (fileName.length > maxName ? '[...]' : '');
const ext = fileUtility.getFileExtension(fileName); // get file extension from the url
let name = baseName + ext; // get full file name
let index = 1;
@ -154,8 +157,8 @@ DocManager.prototype.saveFileData = function saveFileData(fileName, userid, user
const minutes = (dateCreate.getMinutes() < 10 ? '0' : '') + dateCreate.getMinutes().toString();
const month = (dateCreate.getMonth() < 9 ? '0' : '') + (parseInt(dateCreate.getMonth().toString(), 10) + 1);
const sec = (dateCreate.getSeconds() < 10 ? '0' : '') + dateCreate.getSeconds().toString();
const dateFormat = `${dateCreate.getFullYear()}-${month}-${dateCreate.getDate()}`
+ ` ${dateCreate.getHours()}:${minutes}:${sec}`;
const dateFormat = `${dateCreate.getFullYear()}-${month}-${dateCreate.getDate()} `
+ `${dateCreate.getHours()}:${minutes}:${sec}`;
const fileInfo = this.historyPath(fileName, address, true); // get file history information
this.createDirectory(fileInfo); // create a new history directory if it doesn't exist

View File

@ -475,11 +475,12 @@ function getFileInfo($fileId)
function GetCorrectName($fileName, $userAddress = null)
{
$pathParts = pathinfo($fileName);
$maxName = 50;
$ext = mb_strtolower($pathParts['extension']);
$name = $pathParts['basename'];
// get file name from the basename without extension
$baseNameWithoutExt = mb_substr($name, 0, mb_strlen($name) - mb_strlen($ext) - 1);
$baseNameWithoutExt = mb_substr(mb_substr($name, 0, mb_strlen($name) - mb_strlen($ext) - 1), 0, $maxName)
. (strlen($fileName) > $maxName ? "[...]" : "");
$name = $baseNameWithoutExt . "." . $ext;
// if a file with such a name already exists in this directory

View File

@ -78,7 +78,8 @@ def getTemplateImageUrl(fileType, request):
# get file name with an index if such a file name already exists
def getCorrectName(filename, req):
basename = fileUtils.getFileNameWithoutExt(filename)
maxName = 50
basename = fileUtils.getFileNameWithoutExt(filename)[0:maxName] + ('','[...]')[len(filename) > maxName]
ext = fileUtils.getFileExt(filename)
name = f'{basename}{ext}'

View File

@ -149,8 +149,10 @@ class DocumentHelper
# get the correct file name if such a name already exists
def get_correct_name(file_name, user_address)
maxName = 50
ext = File.extname(file_name) # get file extension
base_name = File.basename(file_name, ext) # get file name without extension
# get file name without extension
base_name = File.basename(file_name, ext)[0...maxName] + (file_name.length > maxName ? '[...]' : '')
name = base_name + ext.downcase # get full file name
index = 1