diff --git a/src/js/client.js b/src/js/client.js index 5df3df9ae..eee1d21f7 100644 --- a/src/js/client.js +++ b/src/js/client.js @@ -2403,13 +2403,17 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout }; // FileManager API - Client.prototype.filesGet = function (appId, path, callback) { - get('/api/v1/apps/' + appId + '/files/' + path, null, function (error, data, status) { - if (error) return callback(error); - if (status !== 200) return callback(new ClientError(status, data)); + Client.prototype.filesGet = function (appId, path, download, callback) { + if (download) { + window.open(client.apiOrigin + '/api/v1/apps/' + appId + '/files/' + path + '?access_token=' + token); + } else { + get('/api/v1/apps/' + appId + '/files/' + path, null, function (error, data, status) { + if (error) return callback(error); + if (status !== 200) return callback(new ClientError(status, data)); - callback(null, data); - }); + callback(null, data); + }); + } }; Client.prototype.filesRemove = function (appId, path, callback) { diff --git a/src/js/filemanager.js b/src/js/filemanager.js index 0f039d21f..a8f02382a 100644 --- a/src/js/filemanager.js +++ b/src/js/filemanager.js @@ -148,7 +148,7 @@ app.controller('FileManagerController', ['$scope', 'Client', function ($scope, C } $scope.refresh = function () { - Client.filesGet($scope.appId, $scope.cwd, function (error, result) { + Client.filesGet($scope.appId, $scope.cwd, false, function (error, result) { if (error) return Client.error(error); $scope.entries = result.entries; @@ -169,7 +169,7 @@ app.controller('FileManagerController', ['$scope', 'Client', function ($scope, C if (entry.isDirectory) { setDirectory(filePath); } else if (entry.isFile) { - Client.filesGet($scope.appId, filePath, function (error, result) { + Client.filesGet($scope.appId, filePath, true, function (error, result) { if (error) return Client.error(error); console.log('open', result);