Skip to main content

Interface: StorageWriter

server.StorageWriter

An interface to write files to storage within Convex mutation functions.

Hierarchy

Methods

getUrl

getUrl(storageId): Promise<null | string>

Get the URL for a file in storage by its Id<"_storage">.

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

Parameters

NameTypeDescription
storageIdGenericId<"_storage">The Id<"_storage"> 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

StorageReader.getUrl

Defined in

server/storage.ts:51

getUrl<T>(storageId): Promise<null | string>

Deprecated

Passing a string is deprecated, use storage.getUrl(Id<"_storage">) instead.

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

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

Type parameters

NameType
Textends string

Parameters

NameTypeDescription
storageIdT extends { __tableName: any } ? never : TThe 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

StorageReader.getUrl

Defined in

server/storage.ts:63


getMetadata

getMetadata(storageId): Promise<null | FileMetadata>

Deprecated

This function is deprecated, use db.system.get(Id<"_storage">) instead.

Get metadata for a file.

Parameters

NameTypeDescription
storageIdGenericId<"_storage">The Id<"_storage"> of the file.

Returns

Promise<null | FileMetadata>

Inherited from

StorageReader.getMetadata

Defined in

server/storage.ts:75

getMetadata<T>(storageId): Promise<null | FileMetadata>

Deprecated

This function is deprecated, use db.system.get(Id<"_storage">) instead.

Get metadata for a file.

Type parameters

NameType
Textends string

Parameters

NameTypeDescription
storageIdT extends { __tableName: any } ? never : TThe StorageId of the file.

Returns

Promise<null | FileMetadata>

Inherited from

StorageReader.getMetadata

Defined in

server/storage.ts:85


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 Id<"_storage">.

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.

Defined in

server/storage.ts:105


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
storageIdGenericId<"_storage">The Id<"_storage"> of the file to delete from Convex storage.

Returns

Promise<void>

Defined in

server/storage.ts:113

delete<T>(storageId): Promise<void>

Deprecated

Passing a string is deprecated, use storage.delete(Id<"_storage">) instead.

Delete a file from Convex storage.

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

Type parameters

NameType
Textends string

Parameters

NameTypeDescription
storageIdT extends { __tableName: any } ? never : TThe StorageId of the file to delete from Convex storage.

Returns

Promise<void>

Defined in

server/storage.ts:124