buckets
table permissions: noneobjects
table permissions: insert
Disk
cache by default to store the upload urls. You can customize that in the Auth config by changing the resumable.cache
property.The path of the file you want to upload.
The data of the file you want to upload.
Additional options for the upload.
val bucket = supabase.storage.from("avatars")
bucket.upload("myIcon.png", byteArray) \{
upsert = false
\}
//on JVM you can use java.io.File
bucket.upload("myIcon.png", file) \{
upsert = false
\}
val bucket = supabase.storage.from("avatars")
bucket.uploadAsFlow("test.png", byteArrayOf()).collect \{
when(it) \{
is UploadStatus.Progress -> println("Progress: $\{it.totalBytesSend.toFloat() / it.contentLength * 100\}%")
is UploadStatus.Success -> println("Success")
\}
\}
val bucket = supabase.storage.from("avatars")
//JVM/Android:
val upload = bucket.resumable.createOrContinueUpload("icon.png", File("icon.png"))
//Other platforms:
val upload = bucket.resumable.createOrContinueUpload(data = byteArray, source = "this is for continuing previous uploads later", path = "icon.png")
val upload = bucket.resumable.createOrContinueUpload( //Probably better to write an extension function
channel = \{ offset -> /* create ByteReadChannel and seek to offset */ \},
source = "this is for continuing previous uploads later",
size = dataSize,
path = "icon.png"
)
upload.startOrResumeUploading()
upload.pause()
upload.cancel()
upload.stateFlow.collect \{
println("Progress: $\{it.progress * 100\}%")
println("Paused: $\{it.paused\}")
println("Is done: $\{it.isDone\}")
\}
val bucket = supabase.storage.from("avatars")
//only on JVM/Android:
bucket.resumable.continuePreviousFileUploads()
.map \{ it.await() \} //await all uploads. This just makes sure the uploads have an update-to-date url. You can also do this in parallel
.forEach \{ upload ->
upload.startOrResumeUploading()
\}
//on other platforms you may have to continue uploads from the source (Probably better to write an extension function):
bucket.resumable.continuePreviousUploads \{ source, offset ->
//create ByteReadChannel from source and seek to offset
\}
.map \{ it.await() \} //await all uploads. This just makes sure the uploads have an update-to-date url. You can also do this in parallel
.forEach \{ upload ->
upload.startOrResumeUploading()
\}