Commit ef86de23 authored by Him188's avatar Him188

Fix cuiCloud

parent 8bc10f7b
...@@ -94,9 +94,7 @@ object CuiCloud { ...@@ -94,9 +94,7 @@ object CuiCloud {
filePath: String, filePath: String,
content: ByteArray content: ByteArray
) { ) {
println("uploading to $cuiCloudUrl")
println("filePath=$filePath") println("filePath=$filePath")
println("key=$cuiToken")
println("content=${content.size / 1024 / 1024} MB") println("content=${content.size / 1024 / 1024} MB")
val response = withContext(Dispatchers.IO) { val response = withContext(Dispatchers.IO) {
...@@ -110,20 +108,21 @@ object CuiCloud { ...@@ -110,20 +108,21 @@ object CuiCloud {
) )
} }
} }
if (response.status.isSuccess()) { println(response.status)
println(response.status)
val buffer = ByteArray(4096)
val buffer = ByteArray(4096) val resp = buildList<Byte> {
val resp = buildList<Byte> { while (true) {
while (true) { val read = response.content.readAvailable(buffer, 0, buffer.size)
val read = response.content.readAvailable(buffer, 0, buffer.size) if (read == -1) {
if (read == -1) { break
break
}
addAll(buffer.toList().take(read))
} }
addAll(buffer.toList().take(read))
} }
println(String(resp.toByteArray())) }
println(String(resp.toByteArray()))
if (!response.status.isSuccess()) {
error("Cui cloud response: ${response.status}") error("Cui cloud response: ${response.status}")
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment