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
I tried to create a link like this:
<%= link_to "Video", 'file:///C:/Videos/file.swf', :method => 'post' %>
but not work.
Thanks in advance.
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:
bytes = # load file into variable
send_data(bytes, :filename => “file.swf”, :type => “application/x-shockwave-flash”)
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.