From: Maksym Z. <siq...@gm...> - 2022-07-15 14:51:03
|
Hello, I have a question about how to return the original file name. For example: ns_register_proc GET /dev/rtrn_file ::dev::rtrn_file proc rtrn_file {args} { set f [file join /tmp test.csv] ns_returnfile 200 [ns_guesstype "$f"] $f } When I do GET request I'm getting "rtrn_file.csv" instead of "test.csv" Maybe I'm doing it wrong. Thank you. |
From: Gustaf N. <ne...@wu...> - 2022-07-16 12:08:01
|
Dear Maksym, If no name is provided with the download, the browser can provide a name; the behavior might be different dependent on the browser. Therefore, it is recommended to provide the name via the return header field "Content-Disposition", ... or via the "download" attribute in the link. For details, see [1] all the best -gn [1] https://stackoverflow.com/questions/1628260/downloading-a-file-with-a-different-name-to-the-stored-name ns_register_proc GET /dev/rtrn_file ::dev::rtrn_file namespace eval ::dev { proc rtrn_file {args} { ns_set put [ns_conn outputheaders] Content-Disposition {attachment; filename="test.csv"} set f [file join /tmp test.csv] ns_returnfile 200 [ns_guesstype $f] $f } } |
From: Wolfgang W. <wol...@di...> - 2022-07-18 14:00:16
|
Hi! We use ns_set update [ns_conn outputheaders] Content-Disposition "attachment; filename=\"${filename}\"" for downloading and ns_set update [ns_conn outputheaders] Content-Disposition "filename=\"${filename}\"" for viewing files Am 15.07.22 um 16:50 schrieb Maksym Zinchenko: > Hello, I have a question about how to return the original file name. > For example: > > ns_register_proc GET /dev/rtrn_file ::dev::rtrn_file > proc rtrn_file {args} { > set f [file join /tmp test.csv] > ns_returnfile 200 [ns_guesstype "$f"] $f > } > > When I do GET request I'm getting "rtrn_file.csv" instead of "test.csv" > > Maybe I'm doing it wrong. > > Thank you. > > > _______________________________________________ > naviserver-devel mailing list > nav...@li... > https://lists.sourceforge.net/lists/listinfo/naviserver-devel -- *Wolfgang Winkler* Geschäftsführung wol...@di... mobil +43.699.19971172 dc:*büro* digital concepts Novak Winkler OG Software & Design Landstraße 68, 5. Stock, 4020 Linz www.digital-concepts.com <http://www.digital-concepts.com> tel +43.732.997117.72 tel +43.699.1997117.2 Firmenbuchnummer: 192003h Firmenbuchgericht: Landesgericht Linz |
From: Maksym Z. <siq...@gm...> - 2022-07-19 17:34:18
|
Thank you all, that's exactly what I needed. On Mon, Jul 18, 2022 at 1:00 PM Wolfgang Winkler via naviserver-devel < nav...@li...> wrote: > Hi! > > We use > > ns_set update [ns_conn outputheaders] Content-Disposition "attachment; > filename=\"${filename}\"" > > for downloading and > > ns_set update [ns_conn outputheaders] Content-Disposition > "filename=\"${filename}\"" > > for viewing files > > > Am 15.07.22 um 16:50 schrieb Maksym Zinchenko: > > Hello, I have a question about how to return the original file name. For > example: > > ns_register_proc GET /dev/rtrn_file ::dev::rtrn_file > proc rtrn_file {args} { > set f [file join /tmp test.csv] > ns_returnfile 200 [ns_guesstype "$f"] $f > } > > When I do GET request I'm getting "rtrn_file.csv" instead of "test.csv" > > Maybe I'm doing it wrong. > > Thank you. > > > _______________________________________________ > naviserver-devel mailing lis...@li...https://lists.sourceforge.net/lists/listinfo/naviserver-devel > > -- > > *Wolfgang Winkler* > Geschäftsführung > wol...@di... > mobil +43.699.19971172 > > dc:*büro* > digital concepts Novak Winkler OG > Software & Design > Landstraße 68, 5. Stock, 4020 Linz > www.digital-concepts.com > tel +43.732.997117.72 > tel +43.699.1997117.2 > > Firmenbuchnummer: 192003h > Firmenbuchgericht: Landesgericht Linz > > > _______________________________________________ > naviserver-devel mailing list > nav...@li... > https://lists.sourceforge.net/lists/listinfo/naviserver-devel > |
From: Oscar R. F. <oro...@vr...> - 2022-07-19 21:41:07
|
Dear all, Just for the sake of completeness. If you need an utf-8 encoded filename you may need to encode the filename (as per RFC 5987): ns_set update [ns_conn outputheaders] Content-Disposition "attachment; filename*=UTF-8''[ns_urlencode $filename]" ns_set update [ns_conn outputheaders] Content-Disposition "filename*=UTF-8''[ns_urlencode $filename]" AFAIK it works well in any modern browser. Best regards. -----Mensaje original----- De: Maksym Zinchenko <siq...@gm...> Responder a: nav...@li... Para: nav...@li... Asunto: Re: [naviserver-devel] ns_returnfile return original file name Fecha: Tue, 19 Jul 2022 16:33:58 -0100 Thank you all, that's exactly what I needed. On Mon, Jul 18, 2022 at 1:00 PM Wolfgang Winkler via naviserver-devel <nav...@li...> wrote: > Hi! > We use > ns_set update [ns_conn outputheaders] Content-Disposition > "attachment; filename=\"${filename}\"" > for downloading and > ns_set update [ns_conn outputheaders] Content-Disposition > "filename=\"${filename}\"" > for viewing files > Am 15.07.22 um 16:50 schrieb Maksym Zinchenko: > > > Hello, I have a question about how to return the original file > > name. For example: > > > > ns_register_proc GET /dev/rtrn_file ::dev::rtrn_file > > proc rtrn_file {args} { > > set f [file join /tmp test.csv] > > ns_returnfile 200 [ns_guesstype "$f"] $f > > } > > > > When I do GET request I'm getting "rtrn_file.csv" instead of > > "test.csv" |
From: Gustaf N. <ne...@wu...> - 2022-07-20 20:08:23
|
Dear Oscar, In principle, you are right concerning the encoding. A few comments: - on most browsers, also utf-8 filenames are accepted, but the use of UTF-8 in the header fields is not recommended. - For the percent encoding, one should use "ns_urlencode -path", e.g., ns_urlencode -part path {£ and € rates} since the "ns_urlencode" without parameters (as in your example) uses a special rule for the space character. One should actually provide an API along the lines of: ns_header_field_parameter -charset /charset/ -language /language/ name string to ease its usage. ... maybe something for the next release... All the best -g PS: Minor nitpick: RFC 5987 was obsoleted by RFC 8187 On 19.07.22 23:25, Oscar Rodriguez Fonseca wrote: > Dear all, > > Just for the sake of completeness. If you need an utf-8 encoded > filename you may need to encode the filename (as per RFC 5987): > > ns_set update [ns_conn outputheaders] Content-Disposition "attachment; > filename*=UTF-8''[ns_urlencode $filename]" > > ns_set update [ns_conn outputheaders] Content-Disposition > "filename*=UTF-8''[ns_urlencode $filename]" > > AFAIK it works well in any modern browser. > > Best regards. > > > -----Mensaje original----- > *De*: Maksym Zinchenko <siq...@gm... > <mailto:Maksym%20Zinchenko%20%3cs...@gm...%3e>> > *Responder a*: nav...@li... > *Para*: nav...@li... > *Asunto*: Re: [naviserver-devel] ns_returnfile return original file name > *Fecha*: Tue, 19 Jul 2022 16:33:58 -0100 > > Thank you all, that's exactly what I needed. > > On Mon, Jul 18, 2022 at 1:00 PM Wolfgang Winkler via naviserver-devel > <nav...@li...> wrote: >> >> Hi! >> >> We use >> >> ns_set update [ns_conn outputheaders] Content-Disposition >> "attachment; filename=\"${filename}\"" >> >> for downloading and >> >> ns_set update [ns_conn outputheaders] Content-Disposition >> "filename=\"${filename}\"" >> >> for viewing files >> >> Am 15.07.22 um 16:50 schrieb Maksym Zinchenko: >> >>> Hello, I have a question about how to return the original file name. >>> For example: >>> >>> ns_register_proc GET /dev/rtrn_file ::dev::rtrn_file >>> proc rtrn_file {args} { >>> set f [file join /tmp test.csv] >>> ns_returnfile 200 [ns_guesstype "$f"] $f >>> } >>> >>> When I do GET request I'm getting "rtrn_file.csv" instead of "test.csv" > > > _______________________________________________ > naviserver-devel mailing list > nav...@li... > https://lists.sourceforge.net/lists/listinfo/naviserver-devel -- Univ.Prof. Dr. Gustaf Neumann Head of the Institute of Information Systems and New Media of Vienna University of Economics and Business Program Director of MSc "Information Systems" |
From: Oscar R. F. <oro...@vr...> - 2022-07-20 21:10:10
|
I didn't know that. It seems that most browsers are quite benevolent parsing this with wrong space character encoding. I have to update my code. Thank you very much! -----Mensaje original----- De: Gustaf Neumann <ne...@wu...> Responder a: nav...@li... Para: nav...@li... Asunto: Re: [naviserver-devel] ns_returnfile return original file name Fecha: Wed, 20 Jul 2022 22:08:05 +0200 Dear Oscar, In principle, you are right concerning the encoding. A few comments: - on most browsers, also utf-8 filenames are accepted, but the use of UTF-8 in the header fields is not recommended. - For the percent encoding, one should use "ns_urlencode -path", e.g., ns_urlencode -part path {£ and € rates} since the "ns_urlencode" without parameters (as in your example) uses a special rule for the space character. One should actually provide an API along the lines of: ns_header_field_parameter -charset /charset/ -language /language/ name string to ease its usage. ... maybe something for the next release... All the best -g PS: Minor nitpick: RFC 5987 was obsoleted by RFC 8187 On 19.07.22 23:25, Oscar Rodriguez Fonseca wrote: > Dear all, > > Just for the sake of completeness. If you need an utf-8 encoded > filename you may need to encode the filename (as per RFC 5987): > > ns_set update [ns_conn outputheaders] Content-Disposition > "attachment; filename*=UTF-8''[ns_urlencode $filename]" > > ns_set update [ns_conn outputheaders] Content-Disposition > "filename*=UTF-8''[ns_urlencode $filename]" > > AFAIK it works well in any modern browser. > > Best regards. > > > -----Mensaje original----- > De: Maksym Zinchenko <siq...@gm...> > Responder a: nav...@li... > Para: nav...@li... > Asunto: Re: [naviserver-devel] ns_returnfile return original file > name > Fecha: Tue, 19 Jul 2022 16:33:58 -0100 > > Thank you all, that's exactly what I needed. > > On Mon, Jul 18, 2022 at 1:00 PM Wolfgang Winkler via naviserver- > devel <nav...@li...> wrote: > > > Hi! > > We use > > ns_set update [ns_conn outputheaders] Content-Disposition > > "attachment; filename=\"${filename}\"" > > for downloading and > > ns_set update [ns_conn outputheaders] Content-Disposition > > "filename=\"${filename}\"" > > for viewing files > > Am 15.07.22 um 16:50 schrieb Maksym Zinchenko: > > > > > > > Hello, I have a question about how to return the original file > > > name. For example: > > > > > > ns_register_proc GET /dev/rtrn_file ::dev::rtrn_file > > > proc rtrn_file {args} { > > > set f [file join /tmp test.csv] > > > ns_returnfile 200 [ns_guesstype "$f"] $f > > > } > > > > > > When I do GET request I'm getting "rtrn_file.csv" instead of > > > "test.csv" > > > _______________________________________________ > naviserver-devel mailing list > nav...@li... > https://lists.sourceforge.net/lists/listinfo/naviserver-devel _______________________________________________ naviserver-devel mailing list nav...@li... https://lists.sourceforge.net/lists/listinfo/naviserver-devel |