|
1 | 1 | ## angular-filemanager API docs
|
2 | 2 |
|
3 |
| -#### Listing |
4 |
| - URL: fileManagerConfig.listUrl, Method: POST |
5 |
| -##### JSON Request content |
| 3 | +#### Listing (URL: fileManagerConfig.listUrl, Method: POST) |
| 4 | + |
| 5 | +**JSON Request content** |
6 | 6 | ```json
|
7 | 7 | { "params": {
|
8 | 8 | "mode": "list",
|
9 | 9 | "onlyFolders": false,
|
10 | 10 | "path": "/public_html"
|
11 | 11 | }}
|
12 | 12 | ```
|
13 |
| -##### JSON Response |
| 13 | +**JSON Response** |
14 | 14 | ```json
|
15 | 15 | { "result": [
|
16 | 16 | {
|
|
35 | 35 | ]}
|
36 | 36 | ```
|
37 | 37 | --------------------
|
38 |
| -#### Rename / Move |
39 |
| - URL: fileManagerConfig.renameUrl, Method: POST |
40 |
| -##### JSON Request content |
| 38 | +#### Rename / Move (URL: fileManagerConfig.renameUrl, Method: POST) |
| 39 | +**JSON Request content** |
41 | 40 | ```json
|
42 | 41 | { "params": {
|
43 | 42 | "mode": "rename",
|
44 | 43 | "path": "/public_html/index.php",
|
45 | 44 | "newPath": "/public_html/index2.php"
|
46 | 45 | }}
|
47 | 46 | ```
|
48 |
| -##### JSON Response |
| 47 | +**JSON Response** |
49 | 48 | ```json
|
50 | 49 | { "result": { "success": true, "error": null } }
|
51 | 50 | ```
|
52 | 51 | --------------------
|
53 |
| -#### Copy |
54 |
| - URL: fileManagerConfig.copyUrl, Method: POST |
55 |
| -##### JSON Request content |
| 52 | +#### Copy (URL: fileManagerConfig.copyUrl, Method: POST) |
| 53 | +**JSON Request content** |
56 | 54 | ```json
|
57 | 55 | { "params": {
|
58 | 56 | "mode": "copy",
|
59 | 57 | "path": "/public_html/index.php",
|
60 | 58 | "newPath": "/public_html/index-copy.php"
|
61 | 59 | }}
|
62 | 60 | ```
|
63 |
| -##### JSON Response |
| 61 | +**JSON Response** |
64 | 62 | ```json
|
65 | 63 | { "result": { "success": true, "error": null } }
|
66 | 64 | ```
|
67 | 65 | --------------------
|
68 |
| -#### Remove |
69 |
| - URL: fileManagerConfig.removeUrl, Method: POST |
70 |
| -##### JSON Request content |
| 66 | +#### Remove (URL: fileManagerConfig.removeUrl, Method: POST) |
| 67 | +**JSON Request content** |
71 | 68 | ```json
|
72 | 69 | { "params": {
|
73 | 70 | "mode": "delete",
|
74 | 71 | "path": "/public_html/index.php",
|
75 | 72 | }}
|
76 | 73 | ```
|
77 |
| -##### JSON Response |
| 74 | +**JSON Response** |
78 | 75 | ```json
|
79 | 76 | { "result": { "success": true, "error": null } }
|
80 | 77 | ```
|
81 | 78 | --------------------
|
82 |
| -#### Edit file |
83 |
| - URL: fileManagerConfig.editUrl, Method: POST |
84 |
| -##### JSON Request content |
| 79 | +#### Edit file (URL: fileManagerConfig.editUrl, Method: POST) |
| 80 | +**JSON Request content** |
85 | 81 | ```json
|
86 | 82 | { "params": {
|
87 | 83 | "mode": "savefile",
|
88 | 84 | "content": "<?php echo random(); ?>",
|
89 | 85 | "path": "/public_html/index.php",
|
90 | 86 | }}
|
91 | 87 | ```
|
92 |
| -##### JSON Response |
| 88 | +**JSON Response** |
93 | 89 | ```json
|
94 | 90 | { "result": { "success": true, "error": null } }
|
95 | 91 | ```
|
96 | 92 | --------------------
|
97 |
| -#### Get content of a file |
98 |
| - URL: fileManagerConfig.getContentUrl, Method: POST |
99 |
| -##### JSON Request content |
| 93 | +#### Get content of a file (URL: fileManagerConfig.getContentUrl, Method: POST) |
| 94 | +**JSON Request content** |
100 | 95 | ```json
|
101 | 96 | { "params": {
|
102 | 97 | "mode": "editfile",
|
103 | 98 | "path": "/public_html/index.php"
|
104 | 99 | }}
|
105 | 100 | ```
|
106 |
| -##### JSON Response |
| 101 | +**JSON Response** |
107 | 102 | ```json
|
108 | 103 | { "result": "<?php echo random(); ?>" }
|
109 | 104 | ```
|
110 | 105 | --------------------
|
111 |
| -#### Create folder |
112 |
| - URL: fileManagerConfig.createFolderUrl, Method: POST |
113 |
| -##### JSON Request content |
| 106 | +#### Create folder (URL: fileManagerConfig.createFolderUrl, Method: POST) |
| 107 | +**JSON Request content** |
114 | 108 | ```json
|
115 | 109 | { "params": {
|
116 | 110 | "mode": "addfolder",
|
117 | 111 | "name": "new-folder",
|
118 | 112 | "path": "/public_html"
|
119 | 113 | }}
|
120 | 114 | ```
|
121 |
| -##### JSON Response |
| 115 | +**JSON Response** |
122 | 116 | ```json
|
123 | 117 | { "result": { "success": true, "error": null } }
|
124 | 118 | ```
|
125 | 119 | --------------------
|
126 |
| -#### Set permissions |
127 |
| - URL: fileManagerConfig.permissionsUrl, Method: POST |
128 |
| -##### JSON Request content |
| 120 | +#### Set permissions (URL: fileManagerConfig.permissionsUrl, Method: POST) |
| 121 | +**JSON Request content** |
129 | 122 | ```json
|
130 | 123 | { "params": {
|
131 | 124 | "mode": "changepermissions",
|
|
135 | 128 | "recursive": false
|
136 | 129 | }}
|
137 | 130 | ```
|
138 |
| -##### JSON Response |
| 131 | +**JSON Response** |
139 | 132 | ```json
|
140 | 133 | { "result": { "success": true, "error": null } }
|
141 | 134 | ```
|
142 | 135 | --------------------
|
143 |
| -#### Compress file |
144 |
| - URL: fileManagerConfig.compressUrl, Method: POST |
145 |
| -##### JSON Request content |
| 136 | +#### Compress file (URL: fileManagerConfig.compressUrl, Method: POST) |
| 137 | +**JSON Request content** |
146 | 138 | ```json
|
147 | 139 | { "params": {
|
148 | 140 | "mode": "compress",
|
149 | 141 | "path": "/public_html/compressed.zip",
|
150 | 142 | "destination": "/public_html/backups"
|
151 | 143 | }}
|
152 | 144 | ```
|
153 |
| -##### JSON Response |
| 145 | +**JSON Response** |
154 | 146 | ```json
|
155 | 147 | { "result": { "success": true, "error": null } }
|
156 | 148 | ```
|
157 | 149 | --------------------
|
158 |
| -#### Extract file |
159 |
| - URL: fileManagerConfig.extractUrl, Method: POST |
160 |
| -##### JSON Request content |
| 150 | +#### Extract file (URL: fileManagerConfig.extractUrl, Method: POST) |
| 151 | +**JSON Request content** |
161 | 152 | ```json
|
162 | 153 | { "params": {
|
163 | 154 | "mode": "extract",
|
|
166 | 157 | "sourceFile": "/public_html/compressed.zip"
|
167 | 158 | }}
|
168 | 159 | ```
|
169 |
| -##### JSON Response |
| 160 | +**JSON Response** |
170 | 161 | ```json
|
171 | 162 | { "result": { "success": true, "error": null } }
|
172 | 163 | ```
|
173 | 164 | --------------------
|
174 |
| -#### Upload file |
175 |
| - URL: fileManagerConfig.uploadUrl, Method: POST, Content-Type: multipart/form-data |
176 |
| - Unlimited file upload, each item will be enumerated as file-1, file-2, etc. |
177 |
| -##### Http post params |
| 165 | +#### Upload file (URL: fileManagerConfig.uploadUrl, Method: POST, Content-Type: multipart/form-data) |
| 166 | + |
| 167 | +**Http post request payload** |
178 | 168 | ```
|
179 |
| -[fileManagerConfig.uploadUrl]?destination=/public_html/image.jpg&file-1={..}&file-2={...} |
| 169 | +------WebKitFormBoundaryqBnbHc6RKfXVAf9j |
| 170 | +Content-Disposition: form-data; name="destination" |
| 171 | +/ |
| 172 | +
|
| 173 | +------WebKitFormBoundaryqBnbHc6RKfXVAf9j |
| 174 | +Content-Disposition: form-data; name="file-0"; filename="github.txt" |
| 175 | +Content-Type: text/plain |
180 | 176 | ```
|
181 |
| -##### JSON Response |
| 177 | +**JSON Response** |
182 | 178 | ```json
|
183 | 179 | { "result": { "success": true, "error": null } }
|
184 | 180 | ```
|
| 181 | + |
| 182 | +Unlimited file items to upload, each item will be enumerated as file-0, file-1, etc. |
| 183 | + |
| 184 | +For example, you may retrieve the file in PHP using: |
| 185 | +```php |
| 186 | +$destination = $_POST['destination']; |
| 187 | +$_FILES['file-0'] or foreach($_FILES) |
| 188 | +``` |
185 | 189 | --------------------
|
186 |
| -#### Download / Preview file |
187 |
| - URL: fileManagerConfig.downloadFileUrl, Method: GET |
188 |
| -##### Http query params |
| 190 | +#### Download / Preview file (URL: fileManagerConfig.downloadFileUrl, Method: GET) |
| 191 | +**Http query params** |
189 | 192 | ```
|
190 | 193 | [fileManagerConfig.downloadFileUrl]?mode=download&preview=true&path=/public_html/image.jpg
|
191 | 194 | ```
|
192 |
| -##### Response |
| 195 | +**Response** |
193 | 196 | ```
|
194 | 197 | -File content
|
195 | 198 | ```
|
196 | 199 | --------------------
|
197 | 200 | ##### Errors / Exceptions
|
198 | 201 | Any backend error should be with an error 500 HTTP code.
|
| 202 | + |
199 | 203 | Btw, you can also report errors with a 200 response both using this json structure
|
200 | 204 | ```json
|
201 | 205 | { "result": {
|
|
0 commit comments