Question re ns_return

8 views
Skip to first unread message

Thorpe Mayes

unread,
Nov 22, 2013, 12:52:59 PM11/22/13
to aols...@googlegroups.com
Hi,

I am trying to send multiple files in sequence using ns_return. Only the last file is being sent. 


I have a directory with n files in it, each with a unique name (file_1, file_2, ...)

I am looping through n one step at a time (1, 2, ...)

Here is the code I am using to send the files:


# create and save file to location, then 
set fd [open $current_file]
ns_return 200 application/vnd.ms-excel [read $fd]
close $fd

where current_file is the location of file_n

These files are created dynamically - one at a time with the attempted download happening right after the file is created and saved.

The only file that gets sent is the last file that was created. 

All the files are created and are different. 

I am certainly missing something obvious. Can anyone point me to a solution?

Thanks,

Thorpe



Bernhard van Woerden

unread,
Nov 25, 2013, 5:48:39 AM11/25/13
to aols...@googlegroups.com
You need to return a multipart document like this

You might want to use base64 encoding for each body because writing out the binary correctly can be tricky although I've not tried in this particular case.

Also need to use fconfigure to tell Tcl to set translation to binary.

set fhandle [open $filename r]
fconfigure $fhandle -translation binary
set base64 [::base64::encode [read $fhandle]]
close $fhandle

ns_return will interact with your AOLserver configured output encoding settings so not a good idea to use with binary data.

ns_returnfile will do what you want for one file.

--
Bernhard van Woerden
Qcode Software Limited


--
You received this message because you are subscribed to the Google Groups "AOLserver Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aolserver+...@googlegroups.com.
To post to this group, send email to aols...@googlegroups.com.
Visit this group at http://groups.google.com/group/aolserver.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages