[Rails] Re: Load local files
Your link would render a link on the local user's computer to "file:///C:/Videos/file.swf" - basically, it would link to that file on the user's computer, not the file on the server.
You will have to either place the file within the Web application (under public or assets), or build a controller method to stream what looks like a file in the Web application from the file stored locally. Something like this:
def download_file
bytes = # load file into variable
send_data(bytes, :filename => "file.swf", :type => "application/x-shockwave-flash")
end
That may or may not be the best way though, depending on the size of your file, because the file will be loaded into memory. Some sort of streaming might be necessary - read up on that.
On Thursday, February 21, 2013 8:45:08 AM UTC-5, Ruby-Forum.com User wrote:
Hi,
I have a question about load local files by my application.
I use this code to view a flash video in my app:
<embed src="<%= asset_path('file.swf') %>"/>
This works fine until my swf file is in myapp/app/assets/...
Can I load a flash video from, for example, C:/Videos ? I found nothing
about that.
I tried to create a link like this:
<%= link_to "Video", 'file:///C:/Videos/file.swf', :method => 'post' %>
but not work.
Thanks in advance.
--
Posted via http://www.ruby-forum.com/.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/4W5PTEGiMk4J.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home