This commit is contained in:
parent
0638b7a116
commit
144452a768
@ -28,7 +28,7 @@ apply plugin: 'application'
|
||||
|
||||
group 'com.kmlabz.k8s'
|
||||
version '0.0.1'
|
||||
mainClassName = "io.ktor.server.jetty.EngineMain"
|
||||
mainClassName = "io.ktor.server.tomcat.EngineMain"
|
||||
|
||||
sourceSets {
|
||||
main.kotlin.srcDirs = main.java.srcDirs = ['src']
|
||||
@ -44,11 +44,11 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
implementation "io.ktor:ktor-server-jetty:$ktor_version"
|
||||
implementation "io.ktor:ktor-server-tomcat:$ktor_version"
|
||||
implementation "ch.qos.logback:logback-classic:$logback_version"
|
||||
implementation "io.ktor:ktor-client-core:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-core-jvm:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-jetty:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-apache:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-json-jvm:$ktor_version"
|
||||
implementation "io.ktor:ktor-client-gson:$ktor_version"
|
||||
implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5'
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user