Project

General

Profile

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

 <pre> 
 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" 
     } 
 ]} 

 </pre> 

 It may accepts getting file content: 

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


 { "result": "the content of the file" } 
 </pre> 

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

 There is an other method for file download:  

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

 Http query params 

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

 Response 

 -File content 


 </pre> 


 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.  

 <pre> 
 { "result": { 
     "success": false, 
     "error": "Action not supported" 
 }} 
 </pre> 
  

Back