Skip to content

FilesClient

Defined in: libs/ccs-files-user-client/src/core/client.ts:94

The web user client of the File Service: one client per (tenant, application) context and signed-in user.

  • Uploads: upload(file, input) and files.versions.upload(...) run the whole protocol (ticket, single PUT or parallel parts with progress, pause, resume, cancel, completion); serialize() and resumeUpload(snapshot, file) continue after a reload; FilesClient.uploadFromTicket(ticket, file) runs the same engine on a ticket your backend created, with no Files token at all.
  • Browsing: folders, files, search, tags, trash; sharing: permissions, shares; legal hold: files.hold, holds.
  • Showing: preview(fileId), urls(fileIds) and files.downloadUrl cache signed URLs until a minute before they expire; invalidate(fileId) drops them.
  • signOut() cancels the uploads, clears the caches and the token provider; dispose() releases the client.

new FilesClient(options): FilesClient

Defined in: libs/ccs-files-user-client/src/core/client.ts:125

FilesClientOptions

FilesClient

readonly apiUrl: string

Defined in: libs/ccs-files-user-client/src/core/client.ts:95


readonly tenantId: string

Defined in: libs/ccs-files-user-client/src/core/client.ts:96


readonly applicationId: string

Defined in: libs/ccs-files-user-client/src/core/client.ts:97


readonly routeConfig: Readonly<TokenRouteConfig> | null

Defined in: libs/ccs-files-user-client/src/core/client.ts:99

The token route’s configuration when built with fromTokenRoute (frozen), otherwise null.


readonly folders: FoldersResource

Defined in: libs/ccs-files-user-client/src/core/client.ts:101


readonly files: FilesResource

Defined in: libs/ccs-files-user-client/src/core/client.ts:102


readonly permissions: PermissionsResource

Defined in: libs/ccs-files-user-client/src/core/client.ts:103


readonly shares: SharesResource

Defined in: libs/ccs-files-user-client/src/core/client.ts:104


readonly trash: TrashResource

Defined in: libs/ccs-files-user-client/src/core/client.ts:105


readonly holds: HoldsResource

Defined in: libs/ccs-files-user-client/src/core/client.ts:107

Files under a legal hold (files.manage).


readonly me: MeResource

Defined in: libs/ccs-files-user-client/src/core/client.ts:108


readonly settings: SettingsResource

Defined in: libs/ccs-files-user-client/src/core/client.ts:109


readonly uploads: UploadsRegistry

Defined in: libs/ccs-files-user-client/src/core/client.ts:110

get disposed(): boolean

Defined in: libs/ccs-files-user-client/src/core/client.ts:453

True after dispose() (and signOut()): every call rejects.

boolean

static fromTokenRoute(tokens, overrides?): Promise<FilesClient>

Defined in: libs/ccs-files-user-client/src/core/client.ts:202

Builds a client from your backend’s token route: its answer may carry api_url, tenant_id and application_id, which configure the client; overrides win over the route. The provider also backs getAccessToken, so signOut() clears it.

TokenProvider

FromTokenRouteOverrides = {}

Promise<FilesClient>


static uploadFromTicket(ticket, file, options?): UploadHandle<TicketUploadResult>

Defined in: libs/ccs-files-user-client/src/core/client.ts:241

Runs the upload engine on a ticket your own backend created (flow A): no client, no Files token, the ticket’s signed URLs authorise the PUTs. Progress, parallel parts, retries, pause, resume, cancel and serialize() work as with client.upload; done resolves with { upload_id, file_id, method, parts: [{ part_number, etag }] } for your backend to complete the ticket (parts is empty for a single PUT). Pass a snapshot from serialize() instead of the ticket to continue after a reload (the same file again, or UploadFileMismatchError). Cancelling only stops the PUTs: your backend releases the ticket.

UploadTicket | UploadSnapshot

Blob

UploadFromTicketOptions = {}

UploadHandle<TicketUploadResult>


upload(file, input?, options?): UploadHandle<File>

Defined in: libs/ccs-files-user-client/src/core/client.ts:315

Uploads file (a File or a Blob) as a new file: POST P/uploads with the file’s name, size and type (overridable in input), then the PUTs and the completion. A 413 or 422 (quota, size, type) fails the upload before any byte is sent. done resolves with the File (state: available, processing pending; see files.waitUntilReady).

Blob

UploadInput = {}

UploadOptions = {}

UploadHandle<File>


resumeUpload(snapshot, file): UploadHandle<File>

Defined in: libs/ccs-files-user-client/src/core/client.ts:344

Continues an upload after a reload with the same file (picked again by the user): size and lastModified must match the snapshot (UploadFileMismatchError, thrown at once, otherwise). A multipart ticket that is still open continues from the parts the store holds; a completed one resolves with its file; anything else starts over with a new ticket.

UploadSnapshot

Blob

UploadHandle<File>


preview(fileId, options?): Promise<Preview>

Defined in: libs/ccs-files-user-client/src/core/client.ts:367

What to show for a file: { kind, url, renditions, text?, editable }; kind: 'none' while nothing can be shown. Cached until a minute before the URLs expire (invalidate(fileId) drops it).

string

PreviewOptions = {}

Promise<Preview>


urls(fileIds, options?): Promise<UrlsResult>

Defined in: libs/ccs-files-user-client/src/core/client.ts:390

Signed URLs for up to 200 files in one call (a feed page), one entry per id in order; an id the user may not read gets error instead of url. URLs still cached are not asked for again.

string[]

UrlsOptions = {}

Promise<UrlsResult>


invalidate(fileId): void

Defined in: libs/ccs-files-user-client/src/core/client.ts:430

Drops every cached URL and preview of a file (after it changed: a new version, a rendition, a move).

string

void


search(query?): Promise<SearchResult>

Defined in: libs/ccs-files-user-client/src/core/client.ts:435

GET P/search: arrays are sent as comma lists, custom: { k: v } as custom.k=v; in: ['content'] searches the text.

SearchQuery = {}

Promise<SearchResult>


tags(query?): Promise<TagsResult>

Defined in: libs/ccs-files-user-client/src/core/client.ts:446

Tags in use with their counts; prefix for autocomplete.

TagsQuery = {}

Promise<TagsResult>


signOut(): Promise<void>

Defined in: libs/ccs-files-user-client/src/core/client.ts:461

Ends this user’s session: cancels every upload in progress (releasing their tickets), clears the URL cache and the token provider, then dispose(). Never throws; may be called again.

Promise<void>


dispose(): void

Defined in: libs/ccs-files-user-client/src/core/client.ts:477

Releases the client, for when its context goes away (a tenant or application switch, a destroyed component): pauses every upload in progress (the PUTs in flight stop; the tickets stay, so a snapshot taken with serialize() can still be resumed by another client), clears the URL cache and every listener. Every later call rejects. Idempotent.

void