1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-23 17:02:25 +03:00

use Authorization header in media/v1/upload if enabled, instead of query

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski
2018-06-15 09:57:30 +01:00
parent fdf4523c2a
commit 5e3b1bf6b0

View File

@@ -271,9 +271,18 @@ module.exports.MatrixHttpApi.prototype = {
});
}
});
let url = this.opts.baseUrl + "/_matrix/media/v1/upload";
url += "?access_token=" + encodeURIComponent(this.opts.accessToken);
url += "&filename=" + encodeURIComponent(fileName);
let url = this.opts.baseUrl + "/_matrix/media/v1/upload?";
const queryArgs = ["filename=" + encodeURIComponent(fileName)];
if (this.useAuthorizationHeader) {
xhr.setRequestHeader("Authorization", "Bearer " + this.opts.accessToken);
} else {
queryArgs.push("access_token="
+ encodeURIComponent(this.opts.accessToken));
}
url += queryArgs.join("&");
xhr.open("POST", url);
xhr.setRequestHeader("Content-Type", contentType);