matrix-react-sdk
Version:
SDK for matrix.org using React
38 lines (37 loc) • 2.2 kB
TypeScript
import { MatrixClient, IEventRelation, ISendEventResponse, MatrixEvent, UploadOpts } from "matrix-js-sdk/src/matrix";
import { ImageInfo, EncryptedFile } from "matrix-js-sdk/src/types";
import { RoomUpload } from "./models/RoomUpload";
import { TimelineRenderingType } from "./contexts/RoomContext";
export declare class UploadCanceledError extends Error {
}
/**
* Upload the file to the content repository.
* If the room is encrypted then encrypt the file before uploading.
*
* @param {MatrixClient} matrixClient The matrix client to upload the file with.
* @param {String} roomId The ID of the room being uploaded to.
* @param {File} file The file to upload.
* @param {Function?} progressHandler optional callback to be called when a chunk of
* data is uploaded.
* @param {AbortController?} controller optional abortController to use for this upload.
* @return {Promise} A promise that resolves with an object.
* If the file is unencrypted then the object will have a "url" key.
* If the file is encrypted then the object will have a "file" key.
*/
export declare function uploadFile(matrixClient: MatrixClient, roomId: string, file: File | Blob, progressHandler?: UploadOpts["progressHandler"], controller?: AbortController): Promise<{
url?: string;
file?: EncryptedFile;
}>;
export default class ContentMessages {
private inprogress;
private mediaConfig;
sendStickerContentToRoom(url: string, roomId: string, threadId: string | null, info: ImageInfo, text: string, matrixClient: MatrixClient): Promise<ISendEventResponse>;
getUploadLimit(): number | null;
sendContentListToRoom(files: File[], roomId: string, relation: IEventRelation | undefined, matrixClient: MatrixClient, context?: TimelineRenderingType): Promise<void>;
getCurrentUploads(relation?: IEventRelation): RoomUpload[];
cancelUpload(upload: RoomUpload): void;
sendContentToRoom(file: File, roomId: string, relation: IEventRelation | undefined, matrixClient: MatrixClient, replyToEvent: MatrixEvent | undefined, promBefore?: Promise<any>): Promise<void>;
private isFileSizeAcceptable;
private ensureMediaConfigFetched;
static sharedInstance(): ContentMessages;
}