RTC Forums
November 24, 2024, 11:29:07 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: Send a file via a URL request  (Read 4440 times)
garyk1968
Newbie
*
Posts: 16


« on: February 17, 2011, 01:08:48 PM »

Hi Danijel

I think this is easily sorted. I have RTC running in a small app and what I do is handle REST style requests like /get/customers?index=a etc etc. Works fine and has been for some time. Now what I have done is added a request which returns a zip file to the user. Now whilst it works the filename is actually named the same as the request URL not the filename I am creating. So example;

http://localhost/get/allcustomers

returns a file called 'allcustomers' (no extension) which when I examine the file it does have the right contents. However the file I am building and ideal would like to return is called 'customers.zip'. Just wondering how I acheive this?

Many Thanks

Gary
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: February 17, 2011, 02:39:08 PM »

Setting the 'Content-Disposition' HTTP Header should do the trick for most new browsers:

TRtcDataServer(Sender).Response['Content-Disposition'] := 'attachment; filename="customers.zip"';

For more info on the 'Content-Disposition' HTTP Header, please check section 19.5.1 here:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html

There is also a topic about this and the use of non-standard ASCII characters on StackOverflow:
http://stackoverflow.com/questions/93551/how-to-encode-the-filename-parameter-of-content-disposition-header-in-http

Best Regards,
Danijel Tkalcec
Logged
garyk1968
Newbie
*
Posts: 16


« Reply #2 on: February 17, 2011, 03:32:45 PM »

Thanks Danijel!
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.023 seconds with 16 queries.