diff --git a/Readme.md b/Readme.md
index 9636741c..9dfacc67 100644
--- a/Readme.md
+++ b/Readme.md
@@ -40,6 +40,17 @@ The methods described below are available for all of the test examples.
| **Response** | **Code:** 200 OK
**Success:**
`{"success":true}` |
| **Sample** | **Delete one file:**
`curl -X DELETE http://localhost/file?filename=filename.docx`
**Delete all files:**
`curl -X DELETE http://localhost/file`
|
+
+### GET `/files`
+
+| | |
+| ------------------ | ------------------------------------------------------------ |
+| **Summary** | Get information about all files |
+| **URL** | /files |
+| **Method** | GET |
+| **Response** | **Code:** 200 OK
**Success:**
`[{"version": , "id": , "contentLength": , "pureContentLength": , "title": , "updated": }, ..., {...}]` |
+| **Sample** | `curl -X GET http://localhost/files/` |
+
## Project Information
Official website: [https://www.onlyoffice.com](https://www.onlyoffice.com/?utm_source=github&utm_medium=cpc&utm_campaign=GitHubIntegrationEx)
diff --git a/web/documentserver-example/nodejs/app.js b/web/documentserver-example/nodejs/app.js
index 14a318ce..031d6f7c 100644
--- a/web/documentserver-example/nodejs/app.js
+++ b/web/documentserver-example/nodejs/app.js
@@ -288,6 +288,18 @@ app.get("/convert", function (req, res) {
}
});
+app.get("/files", function(req, res) {
+ try {
+ docManager.init(storageFolder, req, res);
+ const filesInDirectoryInfo = docManager.getFilesInfo();
+ res.write(JSON.stringify(filesInDirectoryInfo));
+ } catch (ex) {
+ console.log(ex);
+ res.write("Server error");
+ }
+ res.end();
+});
+
app.delete("/file", function (req, res) {
try {
docManager.init(storageFolder, req, res);
diff --git a/web/documentserver-example/nodejs/helpers/docManager.js b/web/documentserver-example/nodejs/helpers/docManager.js
index 70ea5523..281944a4 100644
--- a/web/documentserver-example/nodejs/helpers/docManager.js
+++ b/web/documentserver-example/nodejs/helpers/docManager.js
@@ -369,4 +369,24 @@ docManager.cleanFolderRecursive = function (folder, me) {
}
};
+docManager.getFilesInfo = function () {
+ const userAddress = docManager.curUserHostAddress();
+ const directory = path.join(docManager.dir, userAddress);
+ const filesInDirectory = this.getStoredFiles();
+ let responseArray = [];
+ filesInDirectory.forEach((file) => {
+ const stats = fileSystem.lstatSync(path.join(directory, file.name));
+ const fileObject = {
+ version: file.version,
+ id: this.getKey(file.name),
+ contentLength: `${(stats.size/1024).toFixed(2)} KB`,
+ pureContentLength: stats.size,
+ title: file.name,
+ updated: stats.mtime
+ };
+ responseArray.push(fileObject);
+ });
+ return responseArray;
+};
+
module.exports = docManager;