Skip to main content

Interface: StorageActionWriter

server.StorageActionWriter

An interface to read and write files to storage within Convex actions and HTTP actions.

Hierarchy

Methods

getUrl

getUrl(storageId): Promise<null | string>

Get the URL for a file in storage by its StorageId.

The GET response includes a standard HTTP Digest header with a sha256 checksum.

Parameters

NameTypeDescription
storageIdstringThe StorageId of the file to fetch from Convex storage.

Returns

Promise<null | string>

  • A url which fetches the file via an HTTP GET, or null if it no longer exists.

Inherited from

StorageWriter.getUrl

Defined in

server/storage.ts:49


getMetadata

getMetadata(storageId): Promise<null | FileMetadata>

Get metadata for a file.

Parameters

NameTypeDescription
storageIdstringThe StorageId of the file.

Returns

Promise<null | FileMetadata>

Inherited from

StorageWriter.getMetadata

Defined in

server/storage.ts:56


generateUploadUrl

generateUploadUrl(): Promise<string>

Fetch a short-lived URL for uploading a file into storage.

Upon a POST request to this URL, the endpoint will return a JSON object containing a newly allocated StorageId.

The POST URL accepts an optional standard HTTP Digest header with a sha256 checksum.

Returns

Promise<string>

  • A url that allows file upload via an HTTP POST.

Inherited from

StorageWriter.generateUploadUrl

Defined in

server/storage.ts:74


delete

delete(storageId): Promise<void>

Delete a file from Convex storage.

Once a file is deleted, any URLs previously generated by getUrl will return 404s.

Parameters

NameTypeDescription
storageIdstringThe StorageId of the file to delete from Convex storage.

Returns

Promise<void>

Inherited from

StorageWriter.delete

Defined in

server/storage.ts:82


get

get(storageId): Promise<null | Blob>

Get a Blob containing the file associated with the provided StorageId, or null if there is no file.

Parameters

NameType
storageIdstring

Returns

Promise<null | Blob>

Defined in

server/storage.ts:94


store

store(blob, options?): Promise<string>

Store the file contained in the Blob.

If provided, this will verify the sha256 checksum matches the contents of the file.

Parameters

NameType
blobBlob
options?Object
options.sha256?string

Returns

Promise<string>

Defined in

server/storage.ts:100