This commit is contained in:
parent
8bec7d6120
commit
5f42110d75
@ -12,8 +12,8 @@ buildscript {
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
apply plugin: 'kotlin'
|
||||
@ -47,7 +47,6 @@ dependencies {
|
||||
compile 'com.rabbitmq:amqp-client:2.7.1'
|
||||
compile 'com.zaxxer:HikariCP:2.7.8'
|
||||
compile 'com.viartemev:the-white-rabbit:0.0.5'
|
||||
compile 'com.sun.activation:javax.activation:1.2.0'
|
||||
implementation "org.koin:koin-ktor:$koin_version"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
implementation "io.ktor:ktor-server-netty:$ktor_version"
|
||||
@ -66,7 +65,7 @@ kotlin.experimental.coroutines = 'enable'
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
|
||||
kotlinOptions {
|
||||
jvmTarget = "11"
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ services:
|
||||
volumes:
|
||||
- "input-ktor-data:/var/lib/postgresql/data"
|
||||
ports:
|
||||
- "127.0.0.1:54321:5432"
|
||||
- "127.0.0.1:5432:5432"
|
||||
environment:
|
||||
POSTGRES_USER: "input-service"
|
||||
POSTGRES_PASSWORD: "input-service"
|
||||
@ -22,7 +22,6 @@ services:
|
||||
environment:
|
||||
DB_USER: "input-service"
|
||||
DB_PASSWORD: "input-service"
|
||||
POSTGRES_DB: "input-service"
|
||||
DB_URL: "jdbc:postgresql://input-service-postgres:5432/input-service"
|
||||
MQ_HOST: rabbitmq
|
||||
MQ_USERNAME: rabbitmq
|
||||
|
@ -6,11 +6,7 @@ import com.kmalbz.api.model.SampleObject
|
||||
import com.kmalbz.database.service.IInputObjectService
|
||||
import com.rabbitmq.client.BuiltinExchangeType
|
||||
import com.rabbitmq.client.ConnectionFactory
|
||||
import com.rabbitmq.client.MessageProperties
|
||||
import com.typesafe.config.ConfigFactory
|
||||
import com.viartemev.thewhiterabbit.channel.confirmChannel
|
||||
import com.viartemev.thewhiterabbit.channel.publish
|
||||
import com.viartemev.thewhiterabbit.publisher.OutboundMessage
|
||||
import io.ktor.application.call
|
||||
import io.ktor.config.HoconApplicationConfig
|
||||
import io.ktor.http.HttpStatusCode
|
||||
@ -36,7 +32,6 @@ import java.time.LocalDate
|
||||
import java.util.*
|
||||
import javax.activation.MimetypesFileTypeMap
|
||||
|
||||
|
||||
/**
|
||||
* Input Service
|
||||
*
|
||||
@ -79,24 +74,22 @@ class InputServiceServer {
|
||||
when (part) {
|
||||
is PartData.FormItem -> {
|
||||
if (part.name == "description") {
|
||||
print(part.value)
|
||||
description = gson.fromJson(part.value, SampleObject::class.java)
|
||||
}
|
||||
}
|
||||
is PartData.FileItem -> {
|
||||
val file = File(System.getProperty( "java.io.tmpdir"), "upload-${System.currentTimeMillis()}")
|
||||
part.streamProvider().use { input -> file.outputStream().buffered().use { output -> input.copyToSuspend(output) } }
|
||||
val fileType = MimetypesFileTypeMap().getContentType(file)
|
||||
if (fileType != "audio/wave")
|
||||
call.respond(HttpStatusCode.BadRequest)
|
||||
soundFile = file
|
||||
}
|
||||
}
|
||||
part.dispose()
|
||||
}
|
||||
|
||||
if (description == null || soundFile == null)
|
||||
if ((description == null) or (soundFile == null)) {
|
||||
call.respond(HttpStatusCode.ExpectationFailed)
|
||||
return@post
|
||||
}
|
||||
|
||||
val tag = UUID.randomUUID()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user