Project

General

Profile

Actions

User story #9232

closed

User story #9211: Add Directive field with a graphical File Explorer for shared files

Add an API to list shared files properties

Added by François ARMAND about 8 years ago. Updated about 8 years ago.

Status:
Released
Priority:
2
Category:
Web - Config management
Target version:
UX impact:
Suggestion strength:
User visibility:
Effort required:
Name check:
Fix check:
Regression:

Description

For #9211, we need an API that matches angular-filemanger expectation as described here: https://github.com/joni2back/angular-filemanager/blob/master/API.md

The API should be internal, because there is no reason to expose shared-file content until we are able to also modify things in it (i.e until we are able to also upload new shared files). And most likelly, we won't want to have the output required by angular-filemanager, which is not compatible with our format.

So, we have one endpoint: /secure/api/sharedfile

Everything is in POST (yes, yes).

It must accept:

POST /secure/api/sharedfile

{
    "action": "list",
    "path": "/some/path/relative/to/base/directory" 
}

Returns:

{ "result": [ 
    {
        "name": "magento",
        "rights": "drwxr-xr-x",
        "size": "4096",
        "date": "2016-03-03 15:31:40",
        "type": "dir" 
    }, {
        "name": "index.php",
        "rights": "-rw-r--r--",
        "size": "549923",
        "date": "2016-03-03 15:31:40",
        "type": "file" 
    }
]}

It may accepts getting file content:

POST /secure/api/sharedfile
{
    "action": "getContent",
    "item": "/public_html/index.php" 
}

{ "result": "the content of the file" }

Note that for that last method, there is certainly caution to take regarding binary files.

There is an other method for file download:

Download / Preview file (URL: fileManagerConfig.downloadMultipleUrl, Method: GET)

Http query params

[fileManagerConfig.downloadFileUrl]?action=download&path=/public_html/image.jpg

I propose: 

GET /secure/api/sharedfile/download?action=download&path/public_html/impage.jpg

Response

-File content

All other methods must return an error "not supported" (it can also be configured client side). And all error must return a "error 500" status.

{ "result": {
    "success": false,
    "error": "Action not supported" 
}}
Actions

Also available in: Atom PDF