RTC Forums

Subscription => Support => Topic started by: garyk1968 on February 17, 2011, 01:08:48 PM



Title: Send a file via a URL request
Post by: garyk1968 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


Title: Re: Send a file via a URL request
Post by: D.Tkalcec (RTC) 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


Title: Re: Send a file via a URL request
Post by: garyk1968 on February 17, 2011, 03:32:45 PM
Thanks Danijel!