Skip to content

Commit

Permalink
Remove file object V2
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-tennert committed Sep 16, 2024
1 parent 0a0ab0d commit 60992cc
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 62 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
package io.github.jan.supabase.storage

import io.github.jan.supabase.SupabaseSerializer
import io.github.jan.supabase.decode
import io.github.jan.supabase.serializer.KotlinXSerializer
import io.ktor.http.ContentType
import kotlinx.datetime.Instant
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.Transient
import kotlinx.serialization.json.JsonObject

/**
Expand All @@ -30,60 +25,4 @@ data class FileObject(
@SerialName("last_accessed_at")
val lastAccessedAt: Instant?,
val metadata: JsonObject?
)

/**
* Represents a file or a folder in a bucket. If the item is a folder, everything except [name] is null.
* @param name The name of the item
* @param id The id of the item
* @param version The version of the item
* @param bucketId The bucket id of the item
* @param updatedAt The last update date of the item
* @param createdAt The creation date of the item
* @param lastAccessedAt The last access date of the item
* @param metadata The metadata of the item
* @param size The size of the item
* @param rawContentType The content type of the item
* @param etag The etag of the item
* @param lastModified The last modified date of the item
* @param cacheControl The cache control of the item
* @param serializer The serializer to use for decoding the metadata
*/
@Serializable
data class FileObjectV2(
val name: String,
val id: String?,
val version: String,
@SerialName("bucket_id")
val bucketId: String? = null,
@SerialName("updated_at")
val updatedAt: Instant? = null,
@SerialName("created_at")
val createdAt: Instant?,
@SerialName("last_accessed_at")
val lastAccessedAt: Instant? = null,
val metadata: JsonObject?,
val size: Long,
@SerialName("content_type")
val rawContentType: String,
val etag: String?,
@SerialName("last_modified")
val lastModified: Instant?,
@SerialName("cache_control")
val cacheControl: String?,
@Transient @PublishedApi internal val serializer: SupabaseSerializer = KotlinXSerializer()
) {

/**
* The content type of the file
*/
val contentType by lazy {
ContentType.parse(rawContentType)
}

/**
* Decodes the metadata using the [serializer]
*/
inline fun <reified T> decodeMetadata(): T? = metadata?.let { serializer.decode(it.toString()) }

}
)
Empty file.

0 comments on commit 60992cc

Please sign in to comment.