FilesClient
Defined in: libs/ccs-files-client/src/files-client.ts:141
Backend SDK for the File Service, for a trusted server with a machine client: folders, uploads, files, versions, renditions, legal holds, permissions, search, shares, trash, settings, usage, audit, webhooks and (for the Files platform application’s own client) platform administration.
- Tokens: RFC 6749
client_credentials, form-encoded at{issuerUrl}/oauth/tokenwith HTTP Basic auth,scopeandresource; cached untilexp - 60 s, one in-flight token request. A 401 from the API drops the token and replays the request once with a fresh one. - Context: every route lives under
/tenants/:tenant_id/applications/:application_id. A tenant backend setstenantIdandapplicationIdonce; a platform consumer passescontextper call. - Retries: 5xx (not 501) and network errors, up to
maxRetrieswith short exponential backoff and jitter, for reads and idempotent writes (GET, PUT, PATCH, DELETE and the read-like POSTs). A POST that creates carries anIdempotency-Keyfixed before the first attempt and is retried with it; any other POST is never retried. 4xx (429 included) are never retried. - Errors are typed by status: FilesUnauthorizedError (401), FilesForbiddenError (403), FilesNotFoundError (404), FilesConflictError (409), FilesPreconditionFailedError (412), FilesPayloadTooLargeError (413), FilesUnprocessableError (422), FilesRateLimitedError (429), FilesNotImplementedError (501), otherwise FilesApiError.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new FilesClient(
options):FilesClient
Defined in: libs/ccs-files-client/src/files-client.ts:183
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”FilesClient
Properties
Section titled “Properties”folders
Section titled “folders”
readonlyfolders:FoldersResource
Defined in: libs/ccs-files-client/src/files-client.ts:142
uploads
Section titled “uploads”
readonlyuploads:UploadsResource
Defined in: libs/ccs-files-client/src/files-client.ts:143
readonlyfiles:FilesResource
Defined in: libs/ccs-files-client/src/files-client.ts:144
permissions
Section titled “permissions”
readonlypermissions:PermissionsResource
Defined in: libs/ccs-files-client/src/files-client.ts:145
taxonomies
Section titled “taxonomies”
readonlytaxonomies:TaxonomiesResource
Defined in: libs/ccs-files-client/src/files-client.ts:146
shares
Section titled “shares”
readonlyshares:SharesResource
Defined in: libs/ccs-files-client/src/files-client.ts:147
readonlytrash:TrashResource
Defined in: libs/ccs-files-client/src/files-client.ts:148
settings
Section titled “settings”
readonlysettings:SettingsResource
Defined in: libs/ccs-files-client/src/files-client.ts:149
readonlyaudit:AuditResource
Defined in: libs/ccs-files-client/src/files-client.ts:150
webhooks
Section titled “webhooks”
readonlywebhooks:WebhooksResource
Defined in: libs/ccs-files-client/src/files-client.ts:151
readonlyjobs:JobsResource
Defined in: libs/ccs-files-client/src/files-client.ts:152
readonlyholds:HoldsResource
Defined in: libs/ccs-files-client/src/files-client.ts:154
The application’s held files; a file’s hold is files.hold.
platform
Section titled “platform”
readonlyplatform:PlatformResource
Defined in: libs/ccs-files-client/src/files-client.ts:159
Platform administration (no context): only for a client of the Files platform application itself with
files:config.manage; every other client answers 403 platform_admin_required.
endpoints
Section titled “endpoints”
readonlyendpoints:Readonly<{issuerUrl:string;apiUrl:string;resource:string; }>
Defined in: libs/ccs-files-client/src/files-client.ts:162
The Identity Server, API and resource this client talks to, after the defaults were applied.
Methods
Section titled “Methods”verifyWebhookSignature()
Section titled “verifyWebhookSignature()”
staticverifyWebhookSignature(input):boolean
Defined in: libs/ccs-files-client/src/files-client.ts:257
Verifies a webhook delivery: X-Files-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>">, within toleranceSeconds (default 300). Constant-time; false for anything
malformed, tampered or too old. Pass the raw body, never a re-serialised object.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”boolean
upload()
Section titled “upload()”upload(
source,input,options?,context?):Promise<File>
Defined in: libs/ccs-files-client/src/files-client.ts:268
Uploads from the backend in one call: creates the ticket (POST P/uploads with size), PUTs the
bytes (one PUT, or every part with concurrency in flight, each retried up to 5 times), and
completes. Resolves with the File (state: available, processing pending; see
files.waitUntilReady). On give-up the ticket is aborted and a FilesUploadError is thrown; API
errors of the ticket and the completion surface as their FilesApiError subclass.
Parameters
Section titled “Parameters”source
Section titled “source”options?
Section titled “options?”UploadOptions = {}
context?
Section titled “context?”Partial<FilesContext>
Returns
Section titled “Returns”Promise<File>
search()
Section titled “search()”search(
query?,context?):Promise<SearchResult>
Defined in: libs/ccs-files-client/src/files-client.ts:284
GET P/search: arrays are sent as comma lists, custom: { k: v } as custom.k=v.
Parameters
Section titled “Parameters”query?
Section titled “query?”SearchQuery = {}
context?
Section titled “context?”Partial<FilesContext>
Returns
Section titled “Returns”Promise<SearchResult>
tags()
Section titled “tags()”tags(
query?,context?):Promise<TagsResult>
Defined in: libs/ccs-files-client/src/files-client.ts:298
Tags in use with their counts, prefix for autocomplete.
Parameters
Section titled “Parameters”query?
Section titled “query?”TagsQuery = {}
context?
Section titled “context?”Partial<FilesContext>
Returns
Section titled “Returns”Promise<TagsResult>
usage()
Section titled “usage()”usage(
context?):Promise<Usage>
Defined in: libs/ccs-files-client/src/files-client.ts:308
The application’s storage usage and quota, with daily: the last 30 days, oldest first.
Parameters
Section titled “Parameters”context?
Section titled “context?”Partial<FilesContext>
Returns
Section titled “Returns”Promise<Usage>
tenantUsage()
Section titled “tenantUsage()”tenantUsage(
context?):Promise<TenantUsage>
Defined in: libs/ccs-files-client/src/files-client.ts:313
The tenant’s usage across its applications (GET /tenants/:tenant_id/usage); needs only tenantId.
Parameters
Section titled “Parameters”context?
Section titled “context?”Partial<FilesContext>
Returns
Section titled “Returns”Promise<TenantUsage>
capabilities()
Section titled “capabilities()”capabilities(
context?):Promise<Capabilities>
Defined in: libs/ccs-files-client/src/files-client.ts:318
GET P/me/capabilities for this machine principal (roles: [], user_id: null).
Parameters
Section titled “Parameters”context?
Section titled “context?”Partial<FilesContext>
Returns
Section titled “Returns”Promise<Capabilities>