Skip to content

Commit 0113aef

Browse files
committed
backend bridge support get content of file
1 parent 5353596 commit 0113aef

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

assets/js/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
(function() {
88
angular.module('FileManagerApp').constant("$config", {
99
appName: "https://github.com/joni2back/angular-filemanager",
10-
listUrl: "/hosting/filemanager/listdirectory",
10+
listUrl: "bridges/php/handler.php",
1111
uploadUrl: "/hosting/filemanager/upload",
1212

1313
renameUrl: "/hosting/filemanager/item/rename",
1414
copyUrl: "/hosting/filemanager/item/copy",
1515
removeUrl: "/hosting/filemanager/item/remove",
1616
editUrl: "/hosting/filemanager/item/edit",
17-
getContentUrl: "/hosting/filemanager/item/content/get",
17+
getContentUrl: "bridges/php/handler.php",
1818
createFolderUrl: "/hosting/filemanager/item/folder/create",
1919
downloadFileUrl: "/hosting/filemanager/item/download",
2020
compressUrl: "/hosting/filemanager/item/compress",

bridges/php/handler.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,34 @@ public static function getApiParam($param) {
3838

3939
class Response {
4040
public function __construct($data) {
41-
echo json_encode($data);
41+
echo json_encode(array('result' => $data));
4242
exit;
4343
}
4444
}
45+
46+
class FileManager extends FtpHelper {
47+
48+
public function getContent($path) {
49+
$localPath = tempnam(sys_get_temp_dir(), 'fmanager_');
50+
$this->download($path, $localPath);
51+
return file_get_contents($localPath);
52+
}
53+
54+
}
55+
4556
ExceptionCatcherJSON::register();
4657

47-
$oFtp = new FtpHelper(array(
48-
'hostname' => '',
49-
'username' => '',
50-
'password' => ''
58+
$oFtp = new FileManager(array(
59+
'hostname' => '200.58.111.120',
60+
'username' => '[email protected]',
61+
'password' => 'FM321xxx'
5162
));
52-
$oFtp->connect();
5363

64+
$oFtp->connect();
5465

5566
if (Request::getApiParam('mode') === 'list') {
5667
new Response($oFtp->listFilesRaw(Request::getApiParam('path')));
68+
}
69+
if (Request::getApiParam('mode') === 'editfile') {
70+
new Response($oFtp->getContent(Request::getApiParam('path')));
5771
}

0 commit comments

Comments
 (0)