User story #9232

Updated by Fran├žois ARMAND over 7 years ago

For #9211, we need an API that matches angular-filemanger expectation as described here: 

 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" 


 { "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 


 I propose:  

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


 -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"