?
Store
TypeThe typed handle files.defineStore returns, with reads, writes, and upload tokens hanging off it.
The handle for one store, returned by files.defineStore. Its reads (get, head, exists, list) and writes (put, delete), plus createUploadToken, all hang off it. Its access mode is pinned when the store is defined.
Store.ts
interface Store { put(content, options?): Promise<StoredFile> get(key): Promise<Buffer> head(key): Promise<Metadata> exists(key): Promise<boolean> list(options?): Promise<{ files, cursor }> delete(key): Promise<void> createUploadToken(options): Promise<Token> }
Fields
put
(content, options?)
Write bytes; returns a StoredFile.
get / head / exists
(key)
Read the bytes, the metadata, or just presence.
list
(options?)
Enumerate objects by prefix, with a cursor.
delete
(key)
Remove one object.
createUploadToken
(options)
Mint a token for a client-direct upload.
Define and use a store
export const Assets = files.defineStore('assets', { access: 'public' }); const file = await Assets.put(buffer, { contentType: 'image/png' });