Interface: IFileStore
Defined in: internal/file-store/types.ts:44
Tenant-scoped file storage; turns reference files by IFileRef.
Implemented by FileStore; the type of IAIGatewayDeps.fileStore, so a host may pass its own in overrides.
Methods
getBytes()
getBytes(
args):Promise<Uint8Array<ArrayBufferLike>>
Defined in: internal/file-store/types.ts:82
getBytes -- the bytes of a file, for the model
About
The inline part of a message: the pointer back into bytes.
Reads the blob at the user's key; a file this user of this tenant does not have is the adapter's 404.
Who needs it
loadInlineFiles (the files of a question) and restoreInlineBytes (the files of a paused run on its resume).
Parameters
args
fileId
string
tenantId
string
userId
string
The user who uploaded the file (IFileRef.userId).
Returns
Promise<Uint8Array<ArrayBufferLike>>
getSignedUrl()
getSignedUrl(
args):Promise<string>
Defined in: internal/file-store/types.ts:102
getSignedUrl -- a short-lived URL of a file, for a screen
About
The bytes without passing through the server: the adapter signs, the browser fetches.
A file this user of this tenant does not have is the adapter's 404.
Who needs it
AIGateway.getFileUrl, for the host's chat screen that shows an uploaded image or opens a PDF.
Parameters
args
fileId
string
tenantId
string
ttlSec?
number
How long the URL stays valid, in seconds.
Default
900
userId
string
The user who uploaded the file (IFileRef.userId).
Returns
Promise<string>
put()
put(
args):Promise<IFileRef>
Defined in: internal/file-store/types.ts:60
put -- stores an upload and returns its pointer
About
Bytes at
<tenantId>/<path>/<userId>/<fileId>, anIFileReffor the turn; nothing else is kept.
Checks before the write: the type must be allowed (400), the name at most 255 characters without control characters
(400; it reaches the model and the memory transcript, so it stays short and on one line), the file not empty (400) and
not over maxBytes (413). The id is a new UUID.
Who needs it
AIGateway.uploadFile, as a call of the uploading user.
Parameters
args
bytes
Uint8Array
mime
string
name
string
tenantId
string
userId
string
Who uploads; the file is stored in this user's folder.
Returns
Promise<IFileRef>
remove()
remove(
args):Promise<void>
Defined in: internal/file-store/types.ts:128
remove -- deletes one file
About
The blob goes; the turn that pointed at it keeps the pointer.
A file that is not there changes nothing.
Who needs it
AIGateway.deleteFile; deleteThreads, for every file the deleted turns pointed at.
Parameters
args
fileId
string
tenantId
string
userId
string
The user who uploaded the file (IFileRef.userId).
Returns
Promise<void>
removeFilesByUser()
removeFilesByUser(
args):Promise<number>
Defined in: internal/file-store/types.ts:148
removeFilesByUser -- deletes every file a user uploaded
About
The user's whole folder in one adapter call, for "forget this user" (D54).
Returns the number of files deleted. The turns that pointed at them keep their pointers.
Who needs it
forgetUser (both modes) and AIGateway.removeFilesByUser.
Parameters
args
tenantId
string
userId
string
Returns
Promise<number>