# How do I force download with LiteSpeed?

**URL:** <https://www.ruby-forum.com/t/how-do-i-force-download-with-litespeed/123003>\
**Category:** Rails\
**Created:** [December 13, 2007, 10:49am UTC](https://www.ruby-forum.com/t/how-do-i-force-download-with-litespeed/123003 "2007-12-13T10:49:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 13, 2007, 10:49am UTC](https://www.ruby-forum.com/t/how-do-i-force-download-with-litespeed/123003/1 "2007-12-13T10:49:08Z")

</div>

Hi!

Searched a long time for this, but haven’t found an answer.

I’m trying to make the user download a special file, no matter what  
mediatype it is (could be jpg, pdf or doc for example).

My code right now is this:

def download\_path( \_id = params[:id])  
result = Philestructure.find( \_id )  
headers[‘X-LiteSpeed-Location’] = “/downloads/  
#{result.phile.file\_name}”  
headers[‘Content-Description’] = “File Transfer”  
headers[‘Content-Type’] = ‘application/force-download’  
headers[‘Content-Disposition’] = “attachment; filename=/downloads/  
#{result.phile.file\_name};”  
headers[‘Content-length’] = result.phile.file\_size  
render :nothing =\> true, :status =\> 200  
end

As you can see it’s a mixed mess of snippets I’ve found on several  
sites. But it won’t work. All it does is rendering the file.

What am I doing wrong?
