In rails there is default method avaialable to donwload the files by users. i.e send_file. So below code will provide the user to download the file 'home/railsway/downloads/huge.zip' if (s)he logged in.
before_filter :login_required
def download
send_file '/home/railsway/downloads/huge.zip', :type=>"application/zip"
end
Apache server needs one extra header called XSend file to download the file. so Use below in case of that.
before_filter :login_required
def download
send_file '/home/railsway/downloads/huge.zip', :type=>"application/zip", :x_sendfile=>true
end
No comments:
Post a Comment