Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File upload #122

Open
Groodian opened this issue Dec 21, 2021 · 10 comments
Open

File upload #122

Groodian opened this issue Dec 21, 2021 · 10 comments

Comments

@Groodian
Copy link

What is the best way to get a list of images as a multipart request?

@Wicpar
Copy link
Collaborator

Wicpar commented Dec 21, 2021

@Groodian
Copy link
Author

Thanks for your reply.
I have already found this but I want to receive a list of images.

Something like this:

@FormDataRequest
data class PatientAddPictures(
    @PartEncoding("image/*")
    val pictures: List<NamedFileInputStream>
)

But this don’t work.

@Wicpar
Copy link
Collaborator

Wicpar commented Dec 21, 2021

You can't have a list of file input streams as a part of type image, right now each part must be named and annotated correctly, you can make them optional though with the nullability. You could make an upload of up to N images each called image1 to imageN in the parameters.

@Groodian Groodian reopened this Dec 21, 2021
@Groodian
Copy link
Author

Now I am using a binary request, but I get this error:

java.lang.IllegalStateException: Acquiring blocking primitives on this dispatcher is not allowed. Consider using async channel or doing withContext(Dispatchers.IO) { call.receive<InputStream>().use { ... } } instead.

I don’t do anything in the route which is using the binary request.

@Wicpar
Copy link
Collaborator

Wicpar commented Dec 22, 2021

Please identify where the error originates, i don't have the environment to reproduce at the moment.

@Groodian
Copy link
Author

java.lang.IllegalStateException: Acquiring blocking primitives on this dispatcher is not allowed. Consider using async channel or doing withContext(Dispatchers.IO) { call.receive<InputStream>().use { ... } } instead.
	at io.ktor.server.engine.DefaultTransformKt.checkSafeParking(DefaultTransform.kt:93)
	at io.ktor.server.engine.DefaultTransformKt.receiveGuardedInputStream(DefaultTransform.kt:88)
	at io.ktor.server.engine.DefaultTransformKt.access$receiveGuardedInputStream(DefaultTransform.kt:1)
	at io.ktor.server.engine.DefaultTransformKt$installDefaultTransformations$2.invokeSuspend(DefaultTransform.kt:50)
	at io.ktor.server.engine.DefaultTransformKt$installDefaultTransformations$2.invoke(DefaultTransform.kt)
	at io.ktor.server.engine.DefaultTransformKt$installDefaultTransformations$2.invoke(DefaultTransform.kt)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:248)
	at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:116)
	at io.ktor.util.pipeline.SuspendFunctionGun.execute(SuspendFunctionGun.kt:136)
	at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:78)
	at io.ktor.request.ApplicationReceiveFunctionsKt.receive(ApplicationReceiveFunctions.kt:116)
	at com.papsign.ktor.openapigen.content.type.binary.BinaryContentTypeParser.parseBody(BinaryContentTypeParser.kt:118)
	at com.papsign.ktor.openapigen.route.OpenAPIRoute$handle$2$2$1$2$1$1.invokeSuspend(OpenAPIRoute.kt:71)
	at com.papsign.ktor.openapigen.route.OpenAPIRoute$handle$2$2$1$2$1$1.invoke(OpenAPIRoute.kt)
	at com.papsign.ktor.openapigen.route.OpenAPIRoute$handle$2$2$1$2$1$1.invoke(OpenAPIRoute.kt)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:248)
	at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:116)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-6$lambda-5$lambda-4$$inlined$throws$1$1.invokeSuspend(Throws.kt:48)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-6$lambda-5$lambda-4$$inlined$throws$1$1.invoke(Throws.kt)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-6$lambda-5$lambda-4$$inlined$throws$1$1.invoke(Throws.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89)
	at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:264)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-6$lambda-5$lambda-4$$inlined$throws$1.invokeSuspend(Throws.kt:47)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-6$lambda-5$lambda-4$$inlined$throws$1.invoke(Throws.kt)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-6$lambda-5$lambda-4$$inlined$throws$1.invoke(Throws.kt)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:248)
	at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:116)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-6$lambda-5$$inlined$throws$1$1.invokeSuspend(Throws.kt:48)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-6$lambda-5$$inlined$throws$1$1.invoke(Throws.kt)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-6$lambda-5$$inlined$throws$1$1.invoke(Throws.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89)
	at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:264)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-6$lambda-5$$inlined$throws$1.invokeSuspend(Throws.kt:47)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-6$lambda-5$$inlined$throws$1.invoke(Throws.kt)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-6$lambda-5$$inlined$throws$1.invoke(Throws.kt)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:248)
	at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:116)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-6$$inlined$throws$1$1.invokeSuspend(Throws.kt:48)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-6$$inlined$throws$1$1.invoke(Throws.kt)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-6$$inlined$throws$1$1.invoke(Throws.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89)
	at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:264)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-6$$inlined$throws$1.invokeSuspend(Throws.kt:47)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-6$$inlined$throws$1.invoke(Throws.kt)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-6$$inlined$throws$1.invoke(Throws.kt)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:248)
	at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:116)
	at de.h_da.fbi.findus.ApplicationKt$module$7$invoke$$inlined$throws$1$1.invokeSuspend(Throws.kt:48)
	at de.h_da.fbi.findus.ApplicationKt$module$7$invoke$$inlined$throws$1$1.invoke(Throws.kt)
	at de.h_da.fbi.findus.ApplicationKt$module$7$invoke$$inlined$throws$1$1.invoke(Throws.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89)
	at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:264)
	at de.h_da.fbi.findus.ApplicationKt$module$7$invoke$$inlined$throws$1.invokeSuspend(Throws.kt:47)
	at de.h_da.fbi.findus.ApplicationKt$module$7$invoke$$inlined$throws$1.invoke(Throws.kt)
	at de.h_da.fbi.findus.ApplicationKt$module$7$invoke$$inlined$throws$1.invoke(Throws.kt)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:248)
	at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:116)
	at io.ktor.util.pipeline.SuspendFunctionGun.execute(SuspendFunctionGun.kt:136)
	at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:78)
	at io.ktor.routing.Routing.executeResult(Routing.kt:155)
	at io.ktor.routing.Routing.interceptor(Routing.kt:39)
	at io.ktor.routing.Routing$Feature$install$1.invokeSuspend(Routing.kt:107)
	at io.ktor.routing.Routing$Feature$install$1.invoke(Routing.kt)
	at io.ktor.routing.Routing$Feature$install$1.invoke(Routing.kt)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:248)
	at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:116)
	at io.ktor.features.ContentNegotiation$Feature$install$1.invokeSuspend(ContentNegotiation.kt:145)
	at io.ktor.features.ContentNegotiation$Feature$install$1.invoke(ContentNegotiation.kt)
	at io.ktor.features.ContentNegotiation$Feature$install$1.invoke(ContentNegotiation.kt)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:248)
	at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:116)
	at io.ktor.features.StatusPages$interceptCall$2.invokeSuspend(StatusPages.kt:102)
	at io.ktor.features.StatusPages$interceptCall$2.invoke(StatusPages.kt)
	at io.ktor.features.StatusPages$interceptCall$2.invoke(StatusPages.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89)
	at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:264)
	at io.ktor.features.StatusPages.interceptCall(StatusPages.kt:101)
	at io.ktor.features.StatusPages.access$interceptCall(StatusPages.kt:18)
	at io.ktor.features.StatusPages$Feature$install$2.invokeSuspend(StatusPages.kt:142)
	at io.ktor.features.StatusPages$Feature$install$2.invoke(StatusPages.kt)
	at io.ktor.features.StatusPages$Feature$install$2.invoke(StatusPages.kt)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:248)
	at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:116)
	at io.ktor.util.pipeline.SuspendFunctionGun.execute(SuspendFunctionGun.kt:136)
	at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:78)
	at io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$2.invokeSuspend(DefaultEnginePipeline.kt:127)
	at io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$2.invoke(DefaultEnginePipeline.kt)
	at io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$2.invoke(DefaultEnginePipeline.kt)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:248)
	at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:116)
	at io.ktor.util.pipeline.SuspendFunctionGun.execute(SuspendFunctionGun.kt:136)
	at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:78)
	at io.ktor.server.netty.NettyApplicationCallHandler$handleRequest$1.invokeSuspend(NettyApplicationCallHandler.kt:123)
	at io.ktor.server.netty.NettyApplicationCallHandler$handleRequest$1.invoke(NettyApplicationCallHandler.kt)
	at io.ktor.server.netty.NettyApplicationCallHandler$handleRequest$1.invoke(NettyApplicationCallHandler.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startCoroutineUndispatched(Undispatched.kt:55)
	at kotlinx.coroutines.BuildersKt__Builders_commonKt.startCoroutineImpl(Builders.common.kt:194)
	at kotlinx.coroutines.BuildersKt.startCoroutineImpl(Unknown Source)
	at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:134)
	at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:56)
	at kotlinx.coroutines.BuildersKt.launch(Unknown Source)
	at io.ktor.server.netty.NettyApplicationCallHandler.handleRequest(NettyApplicationCallHandler.kt:43)
	at io.ktor.server.netty.NettyApplicationCallHandler.channelRead(NettyApplicationCallHandler.kt:34)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.access$600(AbstractChannelHandlerContext.java:61)
	at io.netty.channel.AbstractChannelHandlerContext$7.run(AbstractChannelHandlerContext.java:370)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:469)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.ktor.server.netty.EventLoopGroupProxy$Companion.create$lambda-1$lambda-0(NettyApplicationEngine.kt:251)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)

@Groodian
Copy link
Author

Do you need more information?

@Wicpar
Copy link
Collaborator

Wicpar commented Dec 30, 2021

Not necessarily, i just don't have the mans to fix that during the holiday season...

@Groodian Groodian changed the title Multipart request File upload Jan 19, 2022
@Groodian
Copy link
Author

java.lang.IllegalStateException: Acquiring blocking primitives on this dispatcher is not allowed. Consider using async channel or doing withContext(Dispatchers.IO) { call.receive<InputStream>().use { ... } } instead.
	at io.ktor.server.engine.DefaultTransformKt.checkSafeParking(DefaultTransform.kt:93)
	at io.ktor.server.engine.DefaultTransformKt.receiveGuardedInputStream(DefaultTransform.kt:88)
	at io.ktor.server.engine.DefaultTransformKt.access$receiveGuardedInputStream(DefaultTransform.kt:1)
	at io.ktor.server.engine.DefaultTransformKt$installDefaultTransformations$2.invokeSuspend(DefaultTransform.kt:50)
	at io.ktor.server.engine.DefaultTransformKt$installDefaultTransformations$2.invoke(DefaultTransform.kt)
	at io.ktor.server.engine.DefaultTransformKt$installDefaultTransformations$2.invoke(DefaultTransform.kt)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:248)
	at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:116)
	at io.ktor.util.pipeline.SuspendFunctionGun.execute(SuspendFunctionGun.kt:136)
	at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:78)
	at io.ktor.request.ApplicationReceiveFunctionsKt.receive(ApplicationReceiveFunctions.kt:116)
	at com.papsign.ktor.openapigen.content.type.binary.BinaryContentTypeParser.parseBody(BinaryContentTypeParser.kt:118)
	at com.papsign.ktor.openapigen.route.OpenAPIRoute$handle$2$2$1$2$1$1.invokeSuspend(OpenAPIRoute.kt:71)
	at com.papsign.ktor.openapigen.route.OpenAPIRoute$handle$2$2$1$2$1$1.invoke(OpenAPIRoute.kt)
	at com.papsign.ktor.openapigen.route.OpenAPIRoute$handle$2$2$1$2$1$1.invoke(OpenAPIRoute.kt)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:248)
	at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:116)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-7$lambda-6$lambda-5$$inlined$throws$1$1.invokeSuspend(Throws.kt:48)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-7$lambda-6$lambda-5$$inlined$throws$1$1.invoke(Throws.kt)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-7$lambda-6$lambda-5$$inlined$throws$1$1.invoke(Throws.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89)
	at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:264)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-7$lambda-6$lambda-5$$inlined$throws$1.invokeSuspend(Throws.kt:47)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-7$lambda-6$lambda-5$$inlined$throws$1.invoke(Throws.kt)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-7$lambda-6$lambda-5$$inlined$throws$1.invoke(Throws.kt)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:248)
	at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:116)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-7$lambda-6$$inlined$throws$1$1.invokeSuspend(Throws.kt:48)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-7$lambda-6$$inlined$throws$1$1.invoke(Throws.kt)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-7$lambda-6$$inlined$throws$1$1.invoke(Throws.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89)
	at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:264)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-7$lambda-6$$inlined$throws$1.invokeSuspend(Throws.kt:47)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-7$lambda-6$$inlined$throws$1.invoke(Throws.kt)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-7$lambda-6$$inlined$throws$1.invoke(Throws.kt)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:248)
	at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:116)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-7$$inlined$throws$1$1.invokeSuspend(Throws.kt:48)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-7$$inlined$throws$1$1.invoke(Throws.kt)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-7$$inlined$throws$1$1.invoke(Throws.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89)
	at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:264)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-7$$inlined$throws$1.invokeSuspend(Throws.kt:47)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-7$$inlined$throws$1.invoke(Throws.kt)
	at de.h_da.fbi.findus.routes.PatientRouteKt$patientRoute$lambda-7$$inlined$throws$1.invoke(Throws.kt)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:248)
	at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:116)
	at de.h_da.fbi.findus.ApplicationKt$module$7$invoke$$inlined$throws$1$1.invokeSuspend(Throws.kt:48)
	at de.h_da.fbi.findus.ApplicationKt$module$7$invoke$$inlined$throws$1$1.invoke(Throws.kt)
	at de.h_da.fbi.findus.ApplicationKt$module$7$invoke$$inlined$throws$1$1.invoke(Throws.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89)
	at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:264)
	at de.h_da.fbi.findus.ApplicationKt$module$7$invoke$$inlined$throws$1.invokeSuspend(Throws.kt:47)
	at de.h_da.fbi.findus.ApplicationKt$module$7$invoke$$inlined$throws$1.invoke(Throws.kt)
	at de.h_da.fbi.findus.ApplicationKt$module$7$invoke$$inlined$throws$1.invoke(Throws.kt)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:248)
	at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:116)
	at io.ktor.util.pipeline.SuspendFunctionGun.execute(SuspendFunctionGun.kt:136)
	at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:78)
	at io.ktor.routing.Routing.executeResult(Routing.kt:155)
	at io.ktor.routing.Routing.interceptor(Routing.kt:39)
	at io.ktor.routing.Routing$Feature$install$1.invokeSuspend(Routing.kt:107)
	at io.ktor.routing.Routing$Feature$install$1.invoke(Routing.kt)
	at io.ktor.routing.Routing$Feature$install$1.invoke(Routing.kt)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:248)
	at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:116)
	at io.ktor.features.ContentNegotiation$Feature$install$1.invokeSuspend(ContentNegotiation.kt:145)
	at io.ktor.features.ContentNegotiation$Feature$install$1.invoke(ContentNegotiation.kt)
	at io.ktor.features.ContentNegotiation$Feature$install$1.invoke(ContentNegotiation.kt)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:248)
	at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:116)
	at io.ktor.features.StatusPages$interceptCall$2.invokeSuspend(StatusPages.kt:102)
	at io.ktor.features.StatusPages$interceptCall$2.invoke(StatusPages.kt)
	at io.ktor.features.StatusPages$interceptCall$2.invoke(StatusPages.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89)
	at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:264)
	at io.ktor.features.StatusPages.interceptCall(StatusPages.kt:101)
	at io.ktor.features.StatusPages.access$interceptCall(StatusPages.kt:18)
	at io.ktor.features.StatusPages$Feature$install$2.invokeSuspend(StatusPages.kt:142)
	at io.ktor.features.StatusPages$Feature$install$2.invoke(StatusPages.kt)
	at io.ktor.features.StatusPages$Feature$install$2.invoke(StatusPages.kt)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:248)
	at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:116)
	at io.ktor.util.pipeline.SuspendFunctionGun.execute(SuspendFunctionGun.kt:136)
	at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:78)
	at io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$2.invokeSuspend(DefaultEnginePipeline.kt:127)
	at io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$2.invoke(DefaultEnginePipeline.kt)
	at io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$2.invoke(DefaultEnginePipeline.kt)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:248)
	at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:116)
	at io.ktor.util.pipeline.SuspendFunctionGun.execute(SuspendFunctionGun.kt:136)
	at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:78)
	at io.ktor.server.netty.NettyApplicationCallHandler$handleRequest$1.invokeSuspend(NettyApplicationCallHandler.kt:123)
	at io.ktor.server.netty.NettyApplicationCallHandler$handleRequest$1.invoke(NettyApplicationCallHandler.kt)
	at io.ktor.server.netty.NettyApplicationCallHandler$handleRequest$1.invoke(NettyApplicationCallHandler.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startCoroutineUndispatched(Undispatched.kt:55)
	at kotlinx.coroutines.BuildersKt__Builders_commonKt.startCoroutineImpl(Builders.common.kt:194)
	at kotlinx.coroutines.BuildersKt.startCoroutineImpl(Unknown Source)
	at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:134)
	at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:56)
	at kotlinx.coroutines.BuildersKt.launch(Unknown Source)
	at io.ktor.server.netty.NettyApplicationCallHandler.handleRequest(NettyApplicationCallHandler.kt:43)
	at io.ktor.server.netty.NettyApplicationCallHandler.channelRead(NettyApplicationCallHandler.kt:34)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.access$600(AbstractChannelHandlerContext.java:61)
	at io.netty.channel.AbstractChannelHandlerContext$7.run(AbstractChannelHandlerContext.java:370)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:469)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.ktor.server.netty.EventLoopGroupProxy$Companion.create$lambda-1$lambda-0(NettyApplicationEngine.kt:251)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)

The error occurs on every file upload expect from fileupload in the tests.

@Wicpar
Copy link
Collaborator

Wicpar commented Feb 27, 2022

There have been changes in newer versions of ktor that prevent using streams directly on the ktor thread... There is probably a non blocking alternative that is allowed, but the simplest would be to add an array type that just consumes the stream inside the proper io thread like described by the error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants