Skip to content

Commit

Permalink
fix(android): multipart tests
Browse files Browse the repository at this point in the history
  • Loading branch information
loks0n committed Sep 30, 2024
1 parent beda039 commit a97b595
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,14 @@ class Client @JvmOverloads constructor(
)
}
}
it.value is Payload -> {
val payload = it.value as Payload
if (payload.sourceType == "path") {
builder.addFormDataPart(it.key, payload.filename, File(payload.path).asRequestBody())
} else {
builder.addFormDataPart(it.key, payload.toString())
}
}
else -> {
builder.addFormDataPart(it.key, it.value.toString())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class Payload private constructor() {
}

fun toFile(path: String): File {
Files.createDirectories(Paths.get(path).parent);

val file = File(path)
file.appendBytes(toBinary())
return file
Expand Down
2 changes: 0 additions & 2 deletions templates/kotlin/src/main/kotlin/io/appwrite/Client.kt.twig
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ class Client @JvmOverloads constructor(
)
}
}

it.value is Payload -> {
val payload = it.value as Payload
if (payload.sourceType == "path") {
Expand All @@ -250,7 +249,6 @@ class Client @JvmOverloads constructor(
builder.addFormDataPart(it.key, payload.toString())
}
}

else -> {
builder.addFormDataPart(it.key, it.value.toString())
}
Expand Down

0 comments on commit a97b595

Please sign in to comment.