Add upload progress dialog
This commit is contained in:
@@ -2439,21 +2439,33 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
|
||||
});
|
||||
};
|
||||
|
||||
Client.prototype.filesUpload = function (appId, path, file, callback) {
|
||||
Client.prototype.filesUpload = function (appId, path, file, progressHandler, callback) {
|
||||
var fd = new FormData();
|
||||
fd.append('file', file);
|
||||
|
||||
var config = {
|
||||
headers: { 'Content-Type': undefined },
|
||||
transformRequest: angular.identity
|
||||
};
|
||||
|
||||
post('/api/v1/apps/' + appId + '/files/' + path, fd, config, function (error, data, status) {
|
||||
function done(error, data, status) {
|
||||
if (error) return callback(error);
|
||||
if (status !== 200) return callback(new ClientError(status, data));
|
||||
|
||||
callback(null, data);
|
||||
});
|
||||
}
|
||||
|
||||
$http({
|
||||
url: client.apiOrigin + '/api/v1/apps/' + appId + '/files/' + path,
|
||||
method: 'POST',
|
||||
data: fd,
|
||||
transformRequest: angular.identity,
|
||||
headers: {
|
||||
'Content-Type': undefined,
|
||||
Authorization: 'Bearer ' + token
|
||||
},
|
||||
|
||||
uploadEventHandlers: {
|
||||
progress: function (e) {
|
||||
progressHandler(e.loaded);
|
||||
}
|
||||
}
|
||||
}).success(defaultSuccessHandler(done)).error(defaultErrorHandler(done));
|
||||
};
|
||||
|
||||
client = new Client();
|
||||
|
||||
Reference in New Issue
Block a user