aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorVijay Dev <vijaydev.cse@gmail.com>2011-09-03 02:44:49 +0530
committerVijay Dev <vijaydev.cse@gmail.com>2011-09-03 02:46:09 +0530
commit5b7bcb4959a33d7a31acdd2823eb3272bcd1f322 (patch)
treef4cc394761ecc6342b01b0bab1fdb8d61a418038 /railties
parenta3edf3d2a307630980731b1963721c60ba2a14e0 (diff)
downloadrails-5b7bcb4959a33d7a31acdd2823eb3272bcd1f322.tar.gz
rails-5b7bcb4959a33d7a31acdd2823eb3272bcd1f322.tar.bz2
rails-5b7bcb4959a33d7a31acdd2823eb3272bcd1f322.zip
document send_file guesses content type from the file extension
and remove info about x_send_file option to send_file
Diffstat (limited to 'railties')
-rw-r--r--railties/guides/source/action_controller_overview.textile4
1 files changed, 3 insertions, 1 deletions
diff --git a/railties/guides/source/action_controller_overview.textile b/railties/guides/source/action_controller_overview.textile
index 073e3bddcf..4e47712636 100644
--- a/railties/guides/source/action_controller_overview.textile
+++ b/railties/guides/source/action_controller_overview.textile
@@ -684,9 +684,11 @@ end
This will read and stream the file 4kB at the time, avoiding loading the entire file into memory at once. You can turn off streaming with the +:stream+ option or adjust the block size with the +:buffer_size+ option.
+If +:type+ is not specified, it will be guessed from the file extension specified in +:filename+. If the content type is not registered for the extension, <tt>application/octet-stream</tt> will be used.
+
WARNING: Be careful when using data coming from the client (params, cookies, etc.) to locate the file on disk, as this is a security risk that might allow someone to gain access to files they are not meant to see.
-TIP: It is not recommended that you stream static files through Rails if you can instead keep them in a public folder on your web server. It is much more efficient to let the user download the file directly using Apache or another web server, keeping the request from unnecessarily going through the whole Rails stack. Although if you do need the request to go through Rails for some reason, you can set the +:x_sendfile+ option to true, and Rails will let the web server handle sending the file to the user, freeing up the Rails process to do other things. Note that your web server needs to support the +X-Sendfile+ header for this to work.
+TIP: It is not recommended that you stream static files through Rails if you can instead keep them in a public folder on your web server. It is much more efficient to let the user download the file directly using Apache or another web server, keeping the request from unnecessarily going through the whole Rails stack.
h4. RESTful Downloads