Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for file metadata, info and exists #694

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

jan-tennert
Copy link
Collaborator

@jan-tennert jan-tennert commented Aug 21, 2024

What kind of change does this PR introduce?

Feature

What is the new behavior?

Support for the new user metadata and the new exists and info methods.

client.storage["my-bucket"].upload("file.png", data) {
    userMetadata {
        put("key", "value")
    }
    //Or:
    userMetadata(myCustomObject)
}

Additionally, the Storage plugin now also provides the ability to set a custom serializer.

Additional context

See supabase/storage-js#207

@jan-tennert jan-tennert added the enhancement New feature or request label Aug 21, 2024
@jan-tennert jan-tennert self-assigned this Aug 21, 2024
# Conflicts:
#	Storage/src/commonMain/kotlin/io/github/jan/supabase/storage/BucketApiImpl.kt
@jan-tennert jan-tennert marked this pull request as ready for review August 25, 2024 12:03
@github-actions github-actions bot added the tests label Aug 25, 2024
return storage.api.postJson("object/list/$bucketId", buildJsonObject {
put("prefix", prefix)
putJsonObject(BucketListFilter().apply(filter).build())
}).safeBody()
}

override suspend fun info(path: String): FileObjectV2 {
val response = storage.api.get("object/info/$bucketId/$path")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, lets wait a bit for adding the info method as there is a bug in the JS lib, this should be object/info/public, but there is also a object/info/authenticated.

We're figuring out internally on how we're naming methods.

So lets just wait a bit before merging this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, I commented on the JS PR regarding this. I couldn't make this work on the hosted Supabase instance, but the self-hosted Docker one works.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@grdsdev Any news regarding this?

# Conflicts:
#	Storage/src/commonMain/kotlin/io/github/jan/supabase/storage/BucketApi.kt
#	Storage/src/commonMain/kotlin/io/github/jan/supabase/storage/BucketApiImpl.kt
#	Storage/src/commonMain/kotlin/io/github/jan/supabase/storage/FileObject.kt
#	Storage/src/commonMain/kotlin/io/github/jan/supabase/storage/FlowExt.kt
#	Storage/src/commonTest/kotlin/BucketApiTest.kt
@@ -13,6 +18,7 @@
class UploadOptionBuilder(
@PublishedApi internal val serializer: SupabaseSerializer,
var upsert: Boolean = false,
var userMetadata: JsonObject? = null,

Check warning

Code scanning / detekt

Public properties require documentation. Warning

The property userMetadata is missing documentation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request storage tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants