Operations โ
All operations are defined in the SobjOperations interface. Adapters implement whichever operations they support.
๐ฅ Import โ
ts
import type { SobjOperations } from 'sobj/operations'๐ค put โ
Upload an object.
ts
put(key: string, body: SobjBody, options?: PutOptions): Promise<SobjMetadata>๐ Parameters โ
| Parameter | Type | Description |
|---|---|---|
key | string | Object key |
body | SobjBody | Object content |
options | PutOptions | Upload options |
๐ฆ Returns โ
SobjMetadata โ metadata of the uploaded object.
๐ฅ get โ
Download an object. Returns null if the object does not exist.
ts
get(key: string, options?: GetOptions): Promise<SobjObject | null>๐ Parameters โ
| Parameter | Type | Description |
|---|---|---|
key | string | Object key |
options | GetOptions | Download options |
๐ฆ Returns โ
SobjObject or null.
๐ head โ
Get metadata for an object without downloading its body. Returns null if not found.
ts
head(key: string): Promise<SobjMetadata | null>๐ Parameters โ
| Parameter | Type | Description |
|---|---|---|
key | string | Object key |
๐ฆ Returns โ
SobjMetadata or null.
๐๏ธ delete โ
Remove an object.
ts
delete(key: string): Promise<void>๐ Parameters โ
| Parameter | Type | Description |
|---|---|---|
key | string | Object key |
๐ list โ
List objects in the storage.
ts
list(options?: ListOptions): Promise<SobjList>๐ Parameters โ
| Parameter | Type | Description |
|---|---|---|
options | ListOptions | Listing options |
๐ฆ Returns โ
SobjList โ page of objects and optional cursor.
๐ copy โ
Copy an object to a new key.
ts
copy(source: string, destination: string, options?: CopyOptions): Promise<SobjMetadata>๐ Parameters โ
| Parameter | Type | Description |
|---|---|---|
source | string | Source key |
destination | string | Destination key |
options | CopyOptions | Copy options |
๐ฆ Returns โ
SobjMetadata โ metadata of the copied object.
๐ presign โ
Generate pre-signed URLs for GET and PUT operations.
ts
presign: {
get(key: string, options?: PresignOptions): Promise<string>
put(key: string, options?: PresignPutOptions): Promise<string>
}โก presign.get โ
ts
presign.get(key: string, options?: PresignOptions): Promise<string>โก presign.put โ
ts
presign.put(key: string, options?: PresignPutOptions): Promise<string>๐ฆ multipart โ
Multipart upload operations for large objects.
ts
multipart: {
create(key: string, options?: CreateMultipartOptions): Promise<MultipartUpload>
uploadPart(upload: MultipartUpload, partNumber: number, body: SobjBody): Promise<MultipartPart>
complete(upload: MultipartUpload, parts: readonly MultipartPart[]): Promise<SobjMetadata>
abort(upload: MultipartUpload): Promise<void>
}๐งช Example โ
ts
const upload = await storage.multipart.create('large.bin')
const part1 = await storage.multipart.uploadPart(upload, 1, chunk1)
const part2 = await storage.multipart.uploadPart(upload, 2, chunk2)
const metadata = await storage.multipart.complete(upload, [part1, part2])Part numbers must be between 1 and 10,000 and passed in order to complete.
๐ท๏ธ versioning โ
Object versioning operations.
ts
versioning: {
list(key: string, options?: ListVersionsOptions): Promise<SobjVersions>
get(key: string, version: string, options?: GetOptions): Promise<SobjObject | null>
delete(key: string, version?: string): Promise<void>
}