FilesWorld extension

The files of 12: upload sessions with parts (3.1, 3.2), completion with the check and the scan (3.4), the states of 2, thumbnails (7.3), the transcript (8.2), downloads with Repr-Digest (9.3), tickets (9.2) and attaching (10). The checks are the visibility and the rules of 12 10, nothing else (README).

Example:

world.fileSettings
  ..partBytes = 4
  ..holdScan = true;
// the app uploads; the file shows "being checked"
world.finishScan(fileId);
on

Methods

abortUpload(String principalId, String fileId) → void

Available on FakeWorld, provided by the FilesWorld extension

abortUpload: ends an open own session; the file becomes failed (12 2).
addReadyFile({required String uploaderId, required String channelId, required String name, required String mimeType, required List<int> bytes, String scanStatus = 'clean', String uploadState = 'complete'}) → String

Available on FakeWorld, provided by the FilesWorld extension

A file of uploaderId in channelId that is uploaded and checked already, for tests that start with attachments: scanStatus and uploadState set its state (12 2); returns its ID. Attach it with createMessage and attachment_file_ids.
completeUpload(String principalId, String fileId, JsonMap body) → JsonMap

Available on FakeWorld, provided by the FilesWorld extension

completeUpload (12 3.4): checks the listed parts, joins them, checks size and SHA-256 and scans (or holds the scan, FakeFileSettings.holdScan); returns the File. A completed session answers the file again.
content(String principalId, String fileId, String variant) → (Uint8List, String)

Available on FakeWorld, provided by the FilesWorld extension

The bytes and type of variant (original or a thumbnail) of fileId for principalId (12 9.3).
createTicket(String principalId, String sessionId, String fileId, String variant) → JsonMap

Available on FakeWorld, provided by the FilesWorld extension

createFileTicket (12 9.2): a ticket of variant bound to sessionId, valid for five minutes; returns the API FileTicket with a path below the origin.
createUploadSession(String principalId, String channelId, JsonMap body) → JsonMap

Available on FakeWorld, provided by the FilesWorld extension

createUpload (12 3.1): a session for an UploadCreate body of principalId in channelId, with the parts of FakeFileSettings.partBytes.
deleteOwnFile(String principalId, String fileId) → void

Available on FakeWorld, provided by the FilesWorld extension

deleteFile: deletes an own file that is not attached; 409 conflict for an attached one.
finishScan(String fileId, {String? result}) → void

Available on FakeWorld, provided by the FilesWorld extension

Ends the scan of fileId with result (default FakeFileSettings.scanResult): the file becomes complete; a servable image gets thumbnails and a voice file its duration; appends file.updated (12 3.4).
putPart(String principalId, String fileId, int number, String? contentDigest, Uint8List bytes) → JsonMap

Available on FakeWorld, provided by the FilesWorld extension

uploadPart (12 3.2): stores part number of fileId after the length and digest checks; the same part with the same digest answers again without new work.
putPresignedPart(String fileId, int number, Uint8List bytes) → String

Available on FakeWorld, provided by the FilesWorld extension

A part of a presigned session, PUT to the object store URL of the session (12 3.3); returns the ETag. Throws like putPart.
requestTranscription(String principalId, String fileId) → JsonMap

Available on FakeWorld, provided by the FilesWorld extension

requestTranscription (12 8.2): in mode service the transcript becomes pending; otherwise 409 conflict with reason transcription_unavailable.
setTranscript(String fileId, String text, {String language = 'en', String source = 'agent'}) → void

Available on FakeWorld, provided by the FilesWorld extension

Sets the transcript of fileId to text (transcript_status = done) and appends file.updated (12 8.2).
transcriptOf(String principalId, String fileId) → JsonMap

Available on FakeWorld, provided by the FilesWorld extension

getTranscript (12 8.2): the API Transcript; text only with status done.
uploadState(String principalId, String fileId) → JsonMap

Available on FakeWorld, provided by the FilesWorld extension

getUpload (12 3.2 item 5): the confirmed parts of an own session.
visibleFile(String principalId, String fileId) → FakeFile

Available on FakeWorld, provided by the FilesWorld extension

The file fileId when principalId may read it: the uploader, or anyone who sees the thread of the message it is attached to (12 3.7); else 404 not_found.