Storage operations provide the low-level interface for interacting with S3 or S3-compatible object storage. The write pipeline uses these internally, but they are exported for advanced use cases.
createStorageOperations #
Creates a storage operations instance backed by files-sdk. The adapter selection is based on config.type:
-
"s3"— reads credentials fromAWS_*environment variables -
"minio"— reads credentials fromMINIO_*environment variables
1
2
3
4
5
6
7
8
import { createStorageOperations } from "@lakeql/adapters"
const storage = createStorageOperations({
type: "minio",
bucket: "my-datalake",
endpoint: "http://localhost:9000",
})
Configuration #
| Property | Type |
|---|---|
| type | StorageType |
Storage adapter type. "s3" | |
| bucket | string |
Bucket name. | |
| region? | string |
Region override. Falls back to AWS_DEFAULT_REGION env var for S3. | |
| endpoint? | string |
Custom endpoint. Required for MinIO, optional for S3 (falls back to AWS_ENDPOINT_URL env var). | |
Operations #
The returned object provides these methods:
| Method | Description |
|---|---|
upload(buffer, path) | Upload a Uint8Array to the given path in the bucket |
deletePrefix(prefix) | Delete all objects under the given prefix |
Environment variables #
S3 #
| Variable | Description |
|---|---|
AWS_ACCESS_KEY_ID | AWS access key |
AWS_SECRET_ACCESS_KEY | AWS secret key |
AWS_DEFAULT_REGION | Default region |
AWS_ENDPOINT_URL | Optional custom endpoint |
MinIO #
| Variable | Description |
|---|---|
MINIO_ACCESS_KEY_ID | MinIO access key |
MINIO_SECRET_ACCESS_KEY | MinIO secret key |
endpoint field in the config is required for MinIO. For S3, it's
optional and defaults to the standard AWS endpoint for the region.Error handling #
Storage errors are wrapped in a StorageError with a descriptive message including the operation and path:
1
2
3
4
5
6
7
8
9
10
11
import { StorageError } from "@lakeql/adapters"
try {
await storage.upload(buffer, "path/to/file.parquet")
} catch (error) {
if (error instanceof StorageError) {
console.error(error.message)
// "Storage upload failed for "path/to/file.parquet": The specified bucket does not exist"
}
}
Error class for storage operation failures, providing path and operation context.
Constructor
new StorageError(message, path, operation, options?)Parameters
| Parameter | Type | Default Value |
|---|---|---|
| message | string | — |
| path | string | — |
| operation | "upload" | "delete" | — |
| options? | ErrorOptions | undefined | — |
Properties
| Property | Type | Default Value | |
|---|---|---|---|
| path | string | — | |
Modifiers: public, readonly | |||
| operation | "upload" | "delete" | — | |
Modifiers: public, readonly | |||
Extends
Error