Skip to content

Commit

Permalink
Merge pull request #1850 from matrix-org/travis/fsdk/filemeta
Browse files Browse the repository at this point in the history
Add method for including extra fields when uploading to a tree space
  • Loading branch information
turt2live authored Aug 18, 2021
2 parents 7c1e89f + 768c0e7 commit c2a0c02
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/models/MSC3089TreeSpace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { MatrixClient } from "../client";
import { EventType, IEncryptedFile, MsgType, UNSTABLE_MSC3089_BRANCH, UNSTABLE_MSC3089_LEAF } from "../@types/event";
import { Room } from "./room";
import { logger } from "../logger";
import { MatrixEvent } from "./event";
import { IContent, MatrixEvent } from "./event";
import {
averageBetweenStrings,
DEFAULT_ALPHABET,
Expand Down Expand Up @@ -451,11 +451,14 @@ export class MSC3089TreeSpace {
* @param {string} name The name of the file.
* @param {ArrayBuffer} encryptedContents The encrypted contents.
* @param {Partial<IEncryptedFile>} info The encrypted file information.
* @param {IContent} additionalContent Optional event content fields to include in the message.
* @returns {Promise<void>} Resolves when uploaded.
*/
public async createFile(
name: string,
encryptedContents: ArrayBuffer, info: Partial<IEncryptedFile>,
encryptedContents: ArrayBuffer,
info: Partial<IEncryptedFile>,
additionalContent?: IContent,
): Promise<void> {
const mxc = await this.client.uploadContent(new Blob([encryptedContents]), {
includeFilename: false,
Expand All @@ -464,6 +467,7 @@ export class MSC3089TreeSpace {
info.url = mxc;

const res = await this.client.sendMessage(this.roomId, {
...(additionalContent ?? {}),
msgtype: MsgType.File,
body: name,
url: mxc,
Expand Down

0 comments on commit c2a0c02

Please sign in to comment.