Interface: StorageActionWriter
server.StorageActionWriter
An interface to read and write files to storage within Convex actions and HTTP actions.
Hierarchy
-
↳
StorageActionWriter
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
| Name | Type | Description |
|---|---|---|
storageId | GenericId<"_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
nullif it no longer exists.
Inherited from
Defined in
▸ 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
| Name | Type |
|---|---|
T | extends string |
Parameters
| Name | Type | Description |
|---|---|---|
storageId | T extends { __tableName: any } ? never : T | The StorageId of the file to fetch from Convex storage. |
Returns
Promise<null | string>
- A url which fetches the file via an HTTP GET, or
nullif it no longer exists.
Inherited from
Defined in
getMetadata
▸ getMetadata(storageId): Promise<null | FileMetadata>
Deprecated
This function is deprecated, use db.system.get(Id<"_storage">) instead.
Get metadata for a file.
Parameters
| Name | Type | Description |
|---|---|---|
storageId | GenericId<"_storage"> | The Id<"_storage"> of the file. |
Returns
Promise<null | FileMetadata>
- A FileMetadata object if found or
nullif not found.
Inherited from
Defined in
▸ 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
| Name | Type |
|---|---|
T | extends string |
Parameters
| Name | Type | Description |
|---|---|---|
storageId | T extends { __tableName: any } ? never : T | The StorageId of the file. |
Returns
Promise<null | FileMetadata>
- A FileMetadata object if found or
nullif not found.
Inherited from
Defined in
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.
Inherited from
StorageWriter.generateUploadUrl
Defined in
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
| Name | Type | Description |
|---|---|---|
storageId | GenericId<"_storage"> | The Id<"_storage"> of the file to delete from Convex storage. |
Returns
Promise<void>
Inherited from
Defined in
▸ 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
| Name | Type |
|---|---|
T | extends string |
Parameters
| Name | Type | Description |
|---|---|---|
storageId | T extends { __tableName: any } ? never : T | The StorageId of the file to delete from Convex storage. |
Returns
Promise<void>
Inherited from
Defined in
get
▸ get(storageId): Promise<null | Blob>
Get a Blob containing the file associated with the provided Id<"_storage">, or null if there is no file.
Parameters
| Name | Type |
|---|---|
storageId | GenericId<"_storage"> |
Returns
Promise<null | Blob>
Defined in
▸ get<T>(storageId): Promise<null | Blob>
Deprecated
Passing a string is deprecated, use storage.get(Id<"_storage">) instead.
Get a Blob containing the file associated with the provided StorageId, or null if there is no file.
Type parameters
| Name | Type |
|---|---|
T | extends string |
Parameters
| Name | Type |
|---|---|
storageId | T extends { __tableName: any } ? never : T |
Returns
Promise<null | Blob>
Defined in
store
▸ store(blob, options?): Promise<GenericId<"_storage">>
Store the file contained in the Blob.
If provided, this will verify the sha256 checksum matches the contents of the file.
Parameters
| Name | Type |
|---|---|
blob | Blob |
options? | Object |
options.sha256? | string |
Returns
Promise<GenericId<"_storage">>