Import
You can import and use this package with:Usage
You can use this library to upload files, download files, and delete files:Error handling
The SDK will throw errors in most operations if the request returns a status >=300 or if the request fails entirely (i.e., due to network errors). The type of the error will be aFetchError<ErrorResponse>:
Error type so if you want to just log the error you can
do so like this:
Interfaces
Client
Properties
baseURL
Methods
deleteBrokenMetadata()
- 200: DeleteBrokenMetadataResponse200
Parameters
| Parameter | Type |
|---|---|
options? | RequestInit |
Returns
Promise<FetchResponse<DeleteBrokenMetadataResponse200>>
deleteFile()
- 204: void
Parameters
| Parameter | Type |
|---|---|
id | string |
options? | RequestInit |
Returns
Promise<FetchResponse<void>>
deleteOrphanedFiles()
- 200: DeleteOrphanedFilesResponse200
Parameters
| Parameter | Type |
|---|---|
options? | RequestInit |
Returns
Promise<FetchResponse<DeleteOrphanedFilesResponse200>>
getFile()
- 200: void
- 206: void
- 304: void
- 412: void
Parameters
| Parameter | Type |
|---|---|
id | string |
params? | GetFileParams |
options? | RequestInit |
Returns
Promise<FetchResponse<Blob>>
getFileMetadataHeaders()
- 200: void
- 304: void
- 412: void
Parameters
| Parameter | Type |
|---|---|
id | string |
params? | GetFileMetadataHeadersParams |
options? | RequestInit |
Returns
Promise<FetchResponse<void>>
getFilePresignedURL()
- 200: PresignedURLResponse
Parameters
| Parameter | Type |
|---|---|
id | string |
options? | RequestInit |
Returns
Promise<FetchResponse<PresignedURLResponse>>
getVersion()
- 200: VersionInformation
Parameters
| Parameter | Type |
|---|---|
options? | RequestInit |
Returns
Promise<FetchResponse<VersionInformation>>
listBrokenMetadata()
- 200: ListBrokenMetadataResponse200
Parameters
| Parameter | Type |
|---|---|
options? | RequestInit |
Returns
Promise<FetchResponse<ListBrokenMetadataResponse200>>
listFilesNotUploaded()
- 200: ListFilesNotUploadedResponse200
Parameters
| Parameter | Type |
|---|---|
options? | RequestInit |
Returns
Promise<FetchResponse<ListFilesNotUploadedResponse200>>
listOrphanedFiles()
- 200: ListOrphanedFilesResponse200
Parameters
| Parameter | Type |
|---|---|
options? | RequestInit |
Returns
Promise<FetchResponse<ListOrphanedFilesResponse200>>
pushChainFunction()
Parameters
| Parameter | Type | Description |
|---|---|---|
chainFunction | ChainFunction | The middleware function to add |
Returns
void
replaceFile()
- The isUploaded flag is set to false to mark the file as being updated
- The file content is replaced in the storage backend
- File metadata is updated (size, mime-type, isUploaded, etc.)
- 200: FileMetadata
Parameters
| Parameter | Type |
|---|---|
id | string |
body | ReplaceFileBody |
options? | RequestInit |
Returns
Promise<FetchResponse<FileMetadata>>
uploadFiles()
- 201: UploadFilesResponse201
Parameters
| Parameter | Type |
|---|---|
body | UploadFilesBody |
options? | RequestInit |
Returns
Promise<FetchResponse<UploadFilesResponse201>>
DeleteBrokenMetadataResponse200
Properties
metadata?
DeleteOrphanedFilesResponse200
Properties
files?
ErrorResponse
Error information returned by the API.Properties
error?
ErrorResponseError
Error details.Properties
data?
message
string) - Human-readable error message.
- Example -
"File not found"
ErrorResponseWithProcessedFiles
Error information returned by the API.Properties
error?
processedFiles?
ErrorResponseWithProcessedFilesError
Error details.Properties
data?
message
string) - Human-readable error message.
- Example -
"File not found"
FileMetadata
Comprehensive metadata information about a file in storage.Properties
bucketId
string) - ID of the bucket containing the file.
- Example -
"users-bucket"
createdAt
string) - Timestamp when the file was created.
- Example -
"2023-01-15T12:34:56Z" - Format - date-time
etag
string) - Entity tag for cache validation.
- Example -
"\"a1b2c3d4e5f6\""
id
string) - Unique identifier for the file.
- Example -
"d5e76ceb-77a2-4153-b7da-1f7c115b2ff2"
isUploaded
boolean) - Whether the file has been successfully uploaded.
- Example -
true
metadata?
{"alt":"Profile picture","category":"avatar"}
mimeType
string) - MIME type of the file.
- Example -
"image/jpeg"
name
string) - Name of the file including extension.
- Example -
"profile-picture.jpg"
size
number) - Size of the file in bytes.
- Example -
245678 - Format - int64
updatedAt
string) - Timestamp when the file was last updated.
- Example -
"2023-01-16T09:45:32Z" - Format - date-time
uploadedByUserId?
"abc123def456"
FileSummary
Basic information about a file in storage.Properties
bucketId
string) - ID of the bucket containing the file.
- Example -
"users-bucket"
id
string) - Unique identifier for the file.
- Example -
"d5e76ceb-77a2-4153-b7da-1f7c115b2ff2"
isUploaded
boolean) - Whether the file has been successfully uploaded.
- Example -
true
name
string) - Name of the file including extension.
- Example -
"profile-picture.jpg"
GetFileMetadataHeadersParams
Parameters for the getFileMetadataHeaders method.Properties
b?
f?
- Output format for image files. Use ‘auto’ for content negotiation based on Accept header
h?
q?
w?
GetFileParams
Parameters for the getFile method.Properties
b?
f?
- Output format for image files. Use ‘auto’ for content negotiation based on Accept header
h?
q?
w?
ListBrokenMetadataResponse200
Properties
metadata?
ListFilesNotUploadedResponse200
Properties
metadata?
ListOrphanedFilesResponse200
Properties
files?
PresignedURLResponse
Contains a presigned URL for direct file operations.Properties
expiration
number) - The time in seconds until the URL expires.
- Example -
3600
url
string) - The presigned URL for file operations.
- Example -
"https://storage.example.com/files/abc123?signature=xyz"
ReplaceFileBody
Properties
file?
metadata?
UpdateFileMetadata
Metadata that can be updated for an existing file.Properties
metadata?
{"alt":"Updated image description","category":"profile"}
name?
"renamed-file.jpg"
UploadFileMetadata
Metadata provided when uploading a new file.Properties
id?
"custom-id-123"
metadata?
{"alt":"Custom image","category":"document"}
name?
"custom-filename.png"
UploadFilesBody
Properties
bucket-id?
"user-uploads"
file[]
Blob[]) - Array of files to upload.
metadata[]?
UploadFilesResponse201
Properties
processedFiles
FileMetadata[]) - List of successfully processed files with their metadata.
VersionInformation
Contains version information about the storage service.Properties
buildVersion
string) - The version number of the storage service build.
- Example -
"1.2.3"
Type Aliases
OutputImageFormat
RFC2822Date
Functions
createAPIClient()
Parameters
| Parameter | Type | Default value |
|---|---|---|
baseURL | string | undefined |
chainFunctions | ChainFunction[] | [] |
Returns
Client