Skip to content

StorageBucket

//fluxbase-kotlin/io.github.nimbleflux.fluxbase.storage/StorageBucket

[jvm]
class StorageBucket(http: FluxbaseHttpClient, bucket: String)

Operations on a single storage bucket. Port of StorageBucket from sdk/src/storage.ts.

StorageBucket [jvm]
constructor(http: FluxbaseHttpClient, bucket: String)
Name Summary
copy [jvm]
suspend fun copy(fromPath: String, toPath: String): FluxbaseResponse<Unit>
Copy a file. POSTs /api/v1/storage/{bucket}/copy. Port of copy() in storage.ts.
createSignedUrl [jvm]
suspend fun createSignedUrl(path: String, expiresIn: Int = 3600): FluxbaseResponse<SignedUrlResult>
Create a signed URL for temporary access. POSTs /api/v1/storage/{bucket}/sign/{path}. Port of createSignedUrl() in storage.ts:1261.
download [jvm]
suspend fun download(path: String): FluxbaseResponse<ByteArray>
Download a file as raw bytes. GETs /api/v1/storage/{bucket}/{path}. Port of download() in storage.ts:368.
getPublicUrl [jvm]
fun getPublicUrl(path: String): String
Get the public URL for a file (if the bucket is public). Port of getPublicUrl() in storage.ts.
list [jvm]
suspend fun list(prefix: String? = null, limit: Int? = null, offset: Int? = null): FluxbaseResponse<List<FileObject>>
List files in the bucket (or a prefix). GETs /api/v1/storage/{bucket}. Port of list() in storage.ts:1040.
move [jvm]
suspend fun move(fromPath: String, toPath: String): FluxbaseResponse<Unit>
Move/rename a file. POSTs /api/v1/storage/{bucket}/move. Port of move() in storage.ts.
remove [jvm]
suspend fun remove(path: String): FluxbaseResponse<Unit>
Delete files. DELETEs /api/v1/storage/{bucket}/{path}. Port of remove() in storage.ts:1099.
upload [jvm]
suspend fun upload(path: String, data: ByteArray, contentType: String = "application/octet-stream", upsert: Boolean = false, metadata: Map<String, String>? = null): FluxbaseResponse<UploadResult>
Upload a file (simple upload via POST multipart). Port of upload() in storage.ts:41.