Skip to content

Commit

Permalink
fix(#79-support-search): change upload response body
Browse files Browse the repository at this point in the history
  • Loading branch information
y9Kap committed Oct 30, 2023
1 parent 858fbc3 commit 71c08f8
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package app.meetacy.sdk.engine.ktor.requests.files

import app.meetacy.sdk.engine.ktor.response.models.GenerateIdentityResponse
import app.meetacy.sdk.engine.ktor.apiVersion
import app.meetacy.sdk.engine.ktor.response.bodyAsSuccess
import app.meetacy.sdk.engine.ktor.token
import app.meetacy.sdk.engine.requests.GetFileRequest
import app.meetacy.sdk.engine.requests.UploadFileRequest
import app.meetacy.sdk.files.DownloadableFile
Expand All @@ -18,7 +20,6 @@ import io.ktor.client.statement.*
import io.ktor.http.*
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.coroutineScope
import kotlinx.serialization.json.Json

internal class FilesEngine(
private val baseUrl: Url,
Expand Down Expand Up @@ -57,7 +58,7 @@ internal class FilesEngine(
suspend fun upload(request: UploadFileRequest): UploadFileRequest.Response = coroutineScope {
val url = baseUrl / "files" / "upload"

val string = httpClient.submitFormWithBinaryData(
val response = httpClient.submitFormWithBinaryData(
url = url.string,
formData = formData {
append(
Expand All @@ -73,14 +74,11 @@ internal class FilesEngine(
)
}
) {
header("Api-Version", request.apiVersion.int)
header("Authorization", request.token.string)
}.bodyAsText()

val response = Json.decodeFromString<GenerateIdentityResponse>(string)

val fileId = FileId(response.result)
apiVersion(request.apiVersion)
token(request.token)
}.bodyAsSuccess<String>()

val fileId = FileId(response)
UploadFileRequest.Response(fileId)
}
}

0 comments on commit 71c08f8

Please sign in to comment.