MinIO/S3 storage
Integrating MinIO/S3 storage in your SettleMint dApp
About
The SettleMint MinIO SDK provides a simple way to interact with MinIO object storage through the SettleMint platform. It enables you to easily store and retrieve files using MinIO's S3-compatible API in a secure and scalable manner.
API Reference
Functions
createPresignedUploadUrl()
createPresignedUploadUrl(
client
,fileName
,path
,bucket
,expirySeconds
):Promise
<string
>
Defined in: sdk/minio/src/helpers/functions.ts:243
Creates a presigned upload URL for direct browser uploads
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
client | Client | undefined | The MinIO client to use |
fileName | string | undefined | The file name to use |
path | string | "" | Optional path/folder |
bucket | string | DEFAULT_BUCKET | Optional bucket name (defaults to DEFAULT_BUCKET) |
expirySeconds | number | 3600 | How long the URL should be valid for |
Returns
Promise
<string
>
Presigned URL for PUT operation
Throws
Will throw an error if URL creation fails or client initialization fails
Example
createServerMinioClient()
createServerMinioClient(
options
):object
Defined in: sdk/minio/src/minio.ts:23
Creates a MinIO client for server-side use with authentication.
Parameters
Parameter | Type | Description |
---|---|---|
options | { accessKey : string ; instance : string ; secretKey : string ; } | The server client options for configuring the MinIO client |
options.accessKey | string | The MinIO access key used to authenticate with the MinIO server |
options.instance | string | The URL of the MinIO instance to connect to |
options.secretKey | string | The MinIO secret key used to authenticate with the MinIO server |
Returns
object
An object containing the initialized MinIO client
Name | Type | Defined in |
---|---|---|
client | Client | sdk/minio/src/minio.ts:23 |
Throws
Will throw an error if not called on the server or if the options fail validation
Example
deleteFile()
deleteFile(
client
,fileId
,bucket
):Promise
<boolean
>
Defined in: sdk/minio/src/helpers/functions.ts:196
Deletes a file from storage
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
client | Client | undefined | The MinIO client to use |
fileId | string | undefined | The file identifier/path |
bucket | string | DEFAULT_BUCKET | Optional bucket name (defaults to DEFAULT_BUCKET) |
Returns
Promise
<boolean
>
Success status
Throws
Will throw an error if deletion fails or client initialization fails
Example
getFileById()
getFileById(
client
,fileId
,bucket
):Promise
<FileMetadata
>
Defined in: sdk/minio/src/helpers/functions.ts:123
Gets a single file by its object name
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
client | Client | undefined | The MinIO client to use |
fileId | string | undefined | The file identifier/path |
bucket | string | DEFAULT_BUCKET | Optional bucket name (defaults to DEFAULT_BUCKET) |
Returns
Promise
<FileMetadata
>
File metadata with presigned URL
Throws
Will throw an error if the file doesn't exist or client initialization fails
Example
getFilesList()
getFilesList(
client
,prefix
,bucket
):Promise
<FileMetadata
[]>
Defined in: sdk/minio/src/helpers/functions.ts:62
Gets a list of files with optional prefix filter
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
client | Client | undefined | The MinIO client to use |
prefix | string | "" | Optional prefix to filter files (like a folder path) |
bucket | string | DEFAULT_BUCKET | Optional bucket name (defaults to DEFAULT_BUCKET) |
Returns
Promise
<FileMetadata
[]>
Array of file metadata objects
Throws
Will throw an error if the operation fails or client initialization fails
Example
uploadFile()
uploadFile(
client
,buffer
,objectName
,contentType
,bucket
):Promise
<FileMetadata
>
Defined in: sdk/minio/src/helpers/functions.ts:293
Uploads a buffer directly to storage
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
client | Client | undefined | The MinIO client to use |
buffer | Buffer | undefined | The buffer to upload |
objectName | string | undefined | The full object name/path |
contentType | string | undefined | The content type of the file |
bucket | string | DEFAULT_BUCKET | Optional bucket name (defaults to DEFAULT_BUCKET) |
Returns
Promise
<FileMetadata
>
The uploaded file metadata
Throws
Will throw an error if upload fails or client initialization fails
Example
Interfaces
FileMetadata
Defined in: sdk/minio/src/helpers/schema.ts:29
Type representing file metadata after validation.
Properties
Property | Type | Description | Defined in |
---|---|---|---|
contentType | string | The content type of the file. | sdk/minio/src/helpers/schema.ts:41 |
etag | string | The ETag of the file. | sdk/minio/src/helpers/schema.ts:56 |
id | string | The unique identifier for the file. | sdk/minio/src/helpers/schema.ts:33 |
name | string | The name of the file. | sdk/minio/src/helpers/schema.ts:37 |
size | number | The size of the file in bytes. | sdk/minio/src/helpers/schema.ts:46 |
uploadedAt | string | The date and time the file was uploaded. | sdk/minio/src/helpers/schema.ts:51 |
url? | string | The URL of the file. | sdk/minio/src/helpers/schema.ts:61 |
Variables
DEFAULT_BUCKET
const
DEFAULT_BUCKET:"uploads"
="uploads"
Defined in: sdk/minio/src/helpers/schema.ts:67
Default bucket name to use for file storage when none is specified.
Contributing
We welcome contributions from the community! Please check out our Contributing guide to learn how you can help improve the SettleMint SDK through bug reports, feature requests, documentation updates, or code contributions.
License
The SettleMint SDK is released under the FSL Software License. See the LICENSE file for more details.