Skip to main content

Interface: StorageWriter

server.StorageWriter

An interface to write to storage within Convex mutation functions.

Hierarchy

Methods

getUrl

getUrl(storageId): Promise<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<string>

  • A url which fetches the file via an HTTP GET.

Inherited from

StorageReader.getUrl


store

store(file, sha256): Promise<string>

Store a file directly in Convex storage.

Parameters

NameTypeDescription
fileArrayBufferAn ArrayBuffer containing the file to store.
sha256undefined | ArrayBufferAn optional sha256 hash of the file for Convex to validate.

Returns

Promise<string>

  • A newly allocated StorageId referencing the stored file.

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.

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>