Auth content uploads. Added a mapping function from request > filename. Added exception handling for content uploads. webclient: Only prefix the client API path on doRequest, not doBaseRequest (this would've broken the identity server auth too). Added matrixService.uploadContent. May not require mFileUpload anymore.

This commit is contained in:
Kegan Dougal 2014-08-18 15:50:55 +01:00
parent a18b1a649c
commit 35da1bf4a3
4 changed files with 62 additions and 31 deletions

View file

@ -54,13 +54,14 @@ angular.module('matrixService', [])
params.access_token = config.access_token;
if (path.indexOf(prefixPath) !== 0) {
path = prefixPath + path;
}
return doBaseRequest(config.homeserver, method, path, params, data, undefined);
};
var doBaseRequest = function(baseUrl, method, path, params, data, headers) {
if (path.indexOf(prefixPath) !== 0) {
path = prefixPath + path;
}
return $http({
method: method,
url: baseUrl + path,
@ -319,6 +320,17 @@ angular.module('matrixService', [])
return doBaseRequest(config.identityServer, "POST", path, {}, data, headers);
},
uploadContent: function(file) {
var path = "/matrix/content";
var headers = {
"Content-Type": undefined // undefined means angular will figure it out
};
var params = {
access_token: config.access_token
};
return doBaseRequest(config.homeserver, "POST", path, params, file, headers);
},
// start listening on /events
getEventStream: function(from, timeout) {
var path = "/events";