This commit is contained in:
@ -4,8 +4,7 @@ import com.google.gson.Gson
|
||||
import com.google.gson.GsonBuilder
|
||||
import io.ktor.application.*
|
||||
import io.ktor.client.*
|
||||
import io.ktor.client.engine.jetty.*
|
||||
import io.ktor.client.features.json.*
|
||||
import io.ktor.client.engine.apache.*
|
||||
import io.ktor.client.request.*
|
||||
import io.ktor.client.request.forms.*
|
||||
import io.ktor.http.*
|
||||
@ -14,17 +13,12 @@ import io.ktor.util.*
|
||||
import kotlinx.coroutines.*
|
||||
import java.io.File
|
||||
|
||||
fun main(args: Array<String>): Unit = io.ktor.server.jetty.EngineMain.main(args)
|
||||
fun main(args: Array<String>): Unit = io.ktor.server.tomcat.EngineMain.main(args)
|
||||
|
||||
@KtorExperimentalAPI
|
||||
@Suppress("unused") // Referenced in application.conf
|
||||
@kotlin.jvm.JvmOverloads
|
||||
fun Application.module(testing: Boolean = false) {
|
||||
val client = HttpClient(Jetty) {
|
||||
install(JsonFeature) {
|
||||
serializer = GsonSerializer()
|
||||
}
|
||||
}
|
||||
runBlocking {
|
||||
val cachedFile = File("/app/wave.wav").readBytes()
|
||||
val gson = GsonBuilder().setPrettyPrinting().create()
|
||||
@ -35,7 +29,8 @@ fun Application.module(testing: Boolean = false) {
|
||||
|
||||
@KtorExperimentalAPI
|
||||
suspend fun uploadData(currIteration: Int, gson: Gson, inputSound: ByteArray) {
|
||||
HttpClient(Jetty).use { client ->
|
||||
HttpClient(Apache).use { client ->
|
||||
|
||||
val parts: List<PartData> = formData {
|
||||
val headersBuilder = HeadersBuilder()
|
||||
headersBuilder[HttpHeaders.ContentType] = "audio/wave"
|
||||
|
Reference in New Issue
Block a user