Add upload and download for the webterminal

This commit is contained in:
Girish Ramakrishnan
2017-08-18 20:45:52 -07:00
parent 537fbff4aa
commit 52832c881a
6 changed files with 181 additions and 25 deletions

View File

@@ -1101,6 +1101,19 @@ angular.module('Application').service('Client', ['$http', 'md5', 'Notification',
return (available - needed) >= 0;
};
Client.prototype.uploadFile = function (appId, file, callback) {
var fd = new FormData();
fd.append('file', file);
post('/api/v1/apps/' + appId + '/upload?file=/tmp/' + file.name, fd, {
headers: { 'Content-Type': undefined },
transformRequest: angular.identity
}).success(function(data, status) {
if (status !== 202) return callback(new ClientError(status, data));
callback(null);
}).error(defaultErrorHandler(callback));
};
client = new Client();
return client;
}]);