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)andfiles.versions.upload(...)run the whole protocol (ticket, single PUT or parallel parts with progress, pause, resume, cancel, completion);serialize()andresumeUpload(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)andfiles.downloadUrlcache 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.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new FilesClient(
options):FilesClient
Defined in: libs/ccs-files-user-client/src/core/client.ts:125
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”FilesClient
Properties
Section titled “Properties”apiUrl
Section titled “apiUrl”
readonlyapiUrl:string
Defined in: libs/ccs-files-user-client/src/core/client.ts:95
tenantId
Section titled “tenantId”
readonlytenantId:string
Defined in: libs/ccs-files-user-client/src/core/client.ts:96
applicationId
Section titled “applicationId”
readonlyapplicationId:string
Defined in: libs/ccs-files-user-client/src/core/client.ts:97
routeConfig
Section titled “routeConfig”
readonlyrouteConfig: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.
folders
Section titled “folders”
readonlyfolders:FoldersResource
Defined in: libs/ccs-files-user-client/src/core/client.ts:101
readonlyfiles:FilesResource
Defined in: libs/ccs-files-user-client/src/core/client.ts:102
permissions
Section titled “permissions”
readonlypermissions:PermissionsResource
Defined in: libs/ccs-files-user-client/src/core/client.ts:103
shares
Section titled “shares”
readonlyshares:SharesResource
Defined in: libs/ccs-files-user-client/src/core/client.ts:104
readonlytrash:TrashResource
Defined in: libs/ccs-files-user-client/src/core/client.ts:105
readonlyholds:HoldsResource
Defined in: libs/ccs-files-user-client/src/core/client.ts:107
Files under a legal hold (files.manage).
readonlyme:MeResource
Defined in: libs/ccs-files-user-client/src/core/client.ts:108
settings
Section titled “settings”
readonlysettings:SettingsResource
Defined in: libs/ccs-files-user-client/src/core/client.ts:109
uploads
Section titled “uploads”
readonlyuploads:UploadsRegistry
Defined in: libs/ccs-files-user-client/src/core/client.ts:110
Accessors
Section titled “Accessors”disposed
Section titled “disposed”Get Signature
Section titled “Get Signature”get disposed():
boolean
Defined in: libs/ccs-files-user-client/src/core/client.ts:453
True after dispose() (and signOut()): every call rejects.
Returns
Section titled “Returns”boolean
Methods
Section titled “Methods”fromTokenRoute()
Section titled “fromTokenRoute()”
staticfromTokenRoute(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.
Parameters
Section titled “Parameters”tokens
Section titled “tokens”overrides?
Section titled “overrides?”Returns
Section titled “Returns”Promise<FilesClient>
uploadFromTicket()
Section titled “uploadFromTicket()”
staticuploadFromTicket(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.
Parameters
Section titled “Parameters”ticket
Section titled “ticket”Blob
options?
Section titled “options?”Returns
Section titled “Returns”UploadHandle<TicketUploadResult>
upload()
Section titled “upload()”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).
Parameters
Section titled “Parameters”Blob
input?
Section titled “input?”UploadInput = {}
options?
Section titled “options?”UploadOptions = {}
Returns
Section titled “Returns”resumeUpload()
Section titled “resumeUpload()”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.
Parameters
Section titled “Parameters”snapshot
Section titled “snapshot”Blob
Returns
Section titled “Returns”preview()
Section titled “preview()”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).
Parameters
Section titled “Parameters”fileId
Section titled “fileId”string
options?
Section titled “options?”PreviewOptions = {}
Returns
Section titled “Returns”Promise<Preview>
urls()
Section titled “urls()”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.
Parameters
Section titled “Parameters”fileIds
Section titled “fileIds”string[]
options?
Section titled “options?”UrlsOptions = {}
Returns
Section titled “Returns”Promise<UrlsResult>
invalidate()
Section titled “invalidate()”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).
Parameters
Section titled “Parameters”fileId
Section titled “fileId”string
Returns
Section titled “Returns”void
search()
Section titled “search()”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.
Parameters
Section titled “Parameters”query?
Section titled “query?”SearchQuery = {}
Returns
Section titled “Returns”Promise<SearchResult>
tags()
Section titled “tags()”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.
Parameters
Section titled “Parameters”query?
Section titled “query?”TagsQuery = {}
Returns
Section titled “Returns”Promise<TagsResult>
signOut()
Section titled “signOut()”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.
Returns
Section titled “Returns”Promise<void>
dispose()
Section titled “dispose()”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.
Returns
Section titled “Returns”void