How to pipe the file input stream to response output stream in scalatra .

45 views
Skip to first unread message

Mahendar Goud

unread,
Jan 6, 2020, 7:33:56 AM1/6/20
to scalatra-user
Hi All,

I have api endpoint called download  which need to download a zip file when you hit the api . currently I am reading the files using the file input stream and writing with zipoutput stream to temp location .Now I need to pipe the file input stream to response stream  in scalatra.

Currently Iam using 
Scalatra 2.6


Thanks
J Mahendar

Naoki Takezoe

unread,
Jan 8, 2020, 8:42:09 AM1/8/20
to scalat...@googlegroups.com
Hi Mahendar,

Sorry for the late reply.

Scalatra supports InputStream as a result value of the controller.
https://github.com/scalatra/scalatra/blob/3db831f380ad0ff5d863eb6fa6d98beb8e366222/core/src/main/scala/org/scalatra/ScalatraBase.scala#L444-L447

Thus, simply returning InputStream from your controller should work.
Also, you can return File directly instead of InputStream.

By the way, we have an online chat room on Gitter.
There are some more active users and developers.
It might be better to ask there if you have any questions.
https://gitter.im/scalatra/scalatra

Regards,
Naoki
> --
> You received this message because you are subscribed to the Google Groups "scalatra-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to scalatra-use...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/scalatra-user/6d14b9a0-e97f-4eae-a964-321c3101fb8c%40googlegroups.com.



--
Naoki Takezoe

Mahendar Goud

unread,
Jan 10, 2020, 2:46:10 AM1/10/20
to scalat...@googlegroups.com
Hi Naoki,

Thanks for your reply.It  helped me to progress on my task .

Thanks 
J Mahendar

Reply all
Reply to author
Forward
0 new messages