简体   繁体   English

如何从Rails 3中的文件系统下载文件

[英]how to download file from filesystem in rails 3

I have a filesystem in my app where files are been uploaded via paperclip and i dont know how to download the uploaded files that have been saved in the file system. 我的应用程序中有一个文件系统,该文件中的文件是通过回形针上传的,我不知道如何下载已保存在文件系统中的上传文件。 if i do something like this <%= link_to "Download", file.video.url %> it brings out the download dialog in mozilla but plays the video in google crome. 如果我做这样的事情<%= link_to "Download", file.video.url %>它会在mozilla中弹出下载对话框,但会在Google crome中播放视频。 When i hosted the app it behaves in another dimention, i checked my log file and ic this 当我托管该应用程序时,它表现为另一个维度,我检查了我的日志文件并对此进行了ic

Started GET "/system/audios/3/original/03%20Breakdown.mp3?1317217561" for 41.206.12.58 at 2011-09-28 14:18:13 -0700

ActionController::RoutingError (No route matches [GET] "/system/audios/3/original/03%20Breakdown.mp3"):

i dont know why this is hapenning.. is they a way i can do this by having a seprate download action.. if so i would like to know how. 我不知道这为什么会发生问题..他们是否可以通过单独的下载操作来做到这一点..如果是这样,我想知道如何。 thank you(pls i am using paperclip for the upload) 谢谢(我正在用回形针上传)

Have you considered using send_file ? 您是否考虑过使用send_file It allows you to specify that the file is an attachment. 它允许您指定文件为附件。 The send_file would be in your download action. send_file将在您的下载操作中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM