[2.0] After serving a temp file with Ok.sendFile, can I ensure the removal of the temp file?

822 views
Skip to first unread message

Árni Hermann Reynisson

unread,
Mar 22, 2012, 6:19:18 AM3/22/12
to play-fr...@googlegroups.com
I'm trying out play2 (play2-mini actually) and I'm serving a file which is a temp file, using Ok.sendFile. Is there any way I can guarantee that the temp file gets deleted afterwards? The file resides in a temp folder which is created with Path.createTempDirectory (from scalax.io) and as far as I can tell, the folder only gets deleted when the server process dies.

Also, I want to give my first impression of using play2. It's simple, awesome and a breath of fresh air. Love the integration with akka. Great work!

Thanks.

Guillaume Bort

unread,
Mar 22, 2012, 8:29:11 AM3/22/12
to play-fr...@googlegroups.com
Perhaps sendFile should take an onClose function parameter for this
use case. You should report it.

But for now, if you write your own Enumerator, you get the opportunity
to be notified when the client socket close.

2012/3/22 Árni Hermann Reynisson <arn...@gmail.com>:

> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/play-framework/-/6IU9oGpk0r0J.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to
> play-framewor...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/play-framework?hl=en.

--
Guillaume Bort

Árni Hermann Reynisson

unread,
Mar 22, 2012, 10:05:45 AM3/22/12
to play-fr...@googlegroups.com
Thanks, that worked like a charm.



On Thursday, March 22, 2012 12:29:11 PM UTC, Guillaume Bort wrote:
Perhaps sendFile should take an onClose function parameter for this
use case. You should report it.

But for now, if you write your own Enumerator, you get the opportunity
to be notified when the client socket close.

2012/3/22 Árni Hermann Reynisson <arn...@gmail.com>:
> I'm trying out play2 (play2-mini actually) and I'm serving a file which is a
> temp file, using Ok.sendFile. Is there any way I can guarantee that the temp
> file gets deleted afterwards? The file resides in a temp folder which is
> created with Path.createTempDirectory (from scalax.io) and as far as I can
> tell, the folder only gets deleted when the server process dies.
>
> Also, I want to give my first impression of using play2. It's simple,
> awesome and a breath of fresh air. Love the integration with akka. Great
> work!
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/play-framework/-/6IU9oGpk0r0J.

> To post to this group, send email to play-framework@googlegroups.com.


> To unsubscribe from this group, send email to


> For more options, visit this group at
> http://groups.google.com/group/play-framework?hl=en.

--
Guillaume Bort

Árni Hermann Reynisson

unread,
Mar 25, 2012, 3:49:18 PM3/25/12
to play-fr...@googlegroups.com
Fyi, I submitted a pull request which implements onClose parameter for Ok.sendFile. Feedback would be very welcome.

Reply all
Reply to author
Forward
0 new messages