fix
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2020-05-22 01:47:51 +02:00
parent 8bec7d6120
commit 5f42110d75
3 changed files with 8 additions and 17 deletions

View File

@@ -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()