renderBinary filename problem

354 views
Skip to first unread message

Fırat KÜÇÜK

unread,
Jan 7, 2010, 7:49:38 AM1/7/10
to play-framework
Hi,
I think there is a problem with Content-Disposition: attachment HTTP header.

My Test case:
package controllers;

import java.io.*;
import play.mvc.*;

public class Application extends Controller {

public static void index() {
render();
}

public static void image() {
File f = new java.io.File("play.png");
renderBinary(f, "play_logo.png");
}
}


The output header is:
Content-Disposition: attachment; filename*=utf-8''play_logo.png;
filename="play_logo.png"

This header works great in firefox 3.5 and Safari
But failed in IE6 and Chrome (renames the file the last part of the
URI for instance httpl://localhost:9000/Apllication/image is just
image)
IE7 shows as an inline attachment

--
FIRAT KÜÇÜK

Nicolas

unread,
Jan 7, 2010, 7:51:36 AM1/7/10
to play-framework
Hi,

Which version are you using? Can you report a bug?

Thanks,

Nicolas

Fırat KÜÇÜK

unread,
Jan 7, 2010, 8:02:20 AM1/7/10
to play-fr...@googlegroups.com
revision 793
i did'nt decide it is a bug or not.
may be it can be a ie problem.

i am looking for the rfc docs.
http://www.faqs.org/rfcs/rfc2231.html

07 Ocak 2010 14:51 tarihinde Nicolas <leroux....@gmail.com> yazdı:

> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> 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.
>
>
>
>

--
FIRAT KÜÇÜK

Fırat KÜÇÜK

unread,
Jan 8, 2010, 6:41:49 AM1/8/10
to play-fr...@googlegroups.com
Hi,
i tried Content-Disposition: attachment alternatives for file download.
Most of them does not work on ie6.
And Chrome does not recognize filename*=utf-8''filename.ext.

Or i did not succeed :)

Instead of this i try to send file directly via redirection.

sample routing:
/download/{id} will be redirected to /file/{id}/{fileName}

/download/5 -> /file/5/Setup.exe


But i did not find an appropriate play render method for direct file
content flush.
Those are the binary render methods that i noticed;

- renderBinary(File file) gives "Content-Disposition: inline" header.
- renderBinary(File file, String name) gives "Content-Disposition:
attachment" header.

Is there any method for file content flushing with appropriate MIME type?

07 Ocak 2010 15:02 tarihinde Fırat KÜÇÜK <firat...@gmail.com> yazdı:

--
FIRAT KÜÇÜK

Fırat KÜÇÜK

unread,
Jan 8, 2010, 7:02:31 AM1/8/10
to play-fr...@googlegroups.com
by the way,
i think play needs some response.write methods.
may be response.write(byte[] buf)

08 Ocak 2010 13:41 tarihinde Fırat KÜÇÜK <firat...@gmail.com> yazdı:

--
FIRAT KÜÇÜK

Guillaume Bort

unread,
Jan 8, 2010, 11:24:30 AM1/8/10
to play-fr...@googlegroups.com
From my tests, filename*=utf-8''filename.ext should be ignored by IE6.
But perhaps I'm wrong.

> i think play needs some response.write methods.
> may be response.write(byte[] buf)

You can use:

response.out.write(byte[] buf)

2010/1/8 Fırat KÜÇÜK <firat...@gmail.com>:

Dubnobasswithmyheadman

unread,
Jan 8, 2010, 12:31:00 PM1/8/10
to play-framework
IE6 may not support the extended filename*=utf8 , but it definitely
knows about the classic filename= syntax.
The later was introduced to allow filenames with extended chars.

You may try to define your own CDispo header before renderBinary call,
it won't be overriden by Play.
response.setHeader("Content-Disposition", "attachment; filename=\"" +
name+ "\"") ?

Hope this helps

On Jan 7, 1:49 pm, Fırat KÜÇÜK <firatku...@gmail.com> wrote:

Reply all
Reply to author
Forward
0 new messages