mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
implement attachment uploading in hs api rather than media repo
as we need the access token
This commit is contained in:
parent
9f2c7c1e32
commit
2890a6aff7
@ -220,6 +220,10 @@ export class HomeServerApi {
|
||||
roomKeyForRoomAndSession(version, roomId, sessionId, options = null) {
|
||||
return this._get(`/room_keys/keys/${encodeURIComponent(roomId)}/${encodeURIComponent(sessionId)}`, {version}, null, options);
|
||||
}
|
||||
|
||||
uploadAttachment(blob, filename, options = null) {
|
||||
return this._post("/upload", {filename}, blob, options);
|
||||
}
|
||||
}
|
||||
|
||||
export function tests() {
|
||||
|
@ -72,11 +72,4 @@ export class MediaRepository {
|
||||
return this.downloadPlaintextFile(content.url, content.info?.mimetype, cache);
|
||||
}
|
||||
}
|
||||
|
||||
async upload(bufferHandle, filename) {
|
||||
const url = `${this._homeServer}/_matrix/media/r0/upload?filename=${encodeURIComponent(filename)}`;
|
||||
// TODO: body doesn't take a bufferHandle currently
|
||||
const {content_uri} = await this._platform.request(url, {method: "POST", body: bufferHandle}).response();
|
||||
return content_uri;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user