How to access local hard drive in ruby on rails

Posted on 2009-05-01
Last Modified: 2013-11-13
Hai all,

I am a newbie to ruby on rails and I am working on a project where I need to embed a flash video which has been stored on my local hard drive in my view page. Is there a way I can do it?

Question by:sreekanthvasireddy
    LVL 60

    Assisted Solution

    by:Geert Bormans
    That is generally not a good idea. A web application should not access a local hard drive as the local hard drive,
    but should access it as a virtual folder. You should put the flash video behind the server.
    There are two options for that
    - simply put the video in the public folder: \public\images
    The disadvantage of that is that each request for the video will pass your Ruby on Rails server, with a bad effect on performance
    - put your rails server behind an apache server and link requests for rails throught to the rails server, but handle images and movies directly through apache
    This will be beneficial for performance. Do it this way, if you expect a lot of traffic to the flash video
    LVL 1

    Accepted Solution

    Hai Gertone,

    Thank you for your reply.

    I think I understand what you said, but am unsure about the second method you said. I am sorry I should have been more elaborate earlier and given you more information. Let me explain my circumstance to the best I can.

    I am working on a project where I am thinking of allowing the user to post a video message and view it at a later date. He can do so as I will display a list of messages that the user created. It is in Ruby on Rails. I am able to record the video using a tool called 'Red5recorder', but the problem is the recorder does not work with 'http' protocol, it needs 'rmtp'. Red5recorder requires us to run a rtmp server which is in c:\programfiles\red5recorder\ on my local system.

    My question is:

    Can we access the flv file which is in c:\programfiles\red5recorder\ from my rails. If so, how?

    Thank you for your time.

    LVL 60

    Expert Comment

    by:Geert Bormans

    you did not give me much time to give you more detail :)

    I think you would best keep the videos close to your rails environment... not safe, but you could bring your rails environment close to the red5recorder path.

    Note that configuring apache, which is what I would do, to pull the videos from that directory is a better option. You don't want to pull all these video files through the Ruby on Rails server. That will be very bad for performance.

    Just make an alias to the red5recorder path in apache. There is an apache TA on Experts Exchange where people can help you further configuring apache if you don't succeed
    I really recommend you to use apache in front of the railsserver, for projects like this

    Anyway, you found another approach, which is good.

    Please take note of two things
    - if you found another approach, please post it here for future reference. It might be helpfull to others
    - allthough you did not hear what you wanted to hear in this question, the answer given is still valuable. You can't simply close the question without giving credit to the effort taken, putting you in the right direction... that is why I object to you closure
    LVL 1

    Author Comment

    Hai Gertone,

    You can't simply close the question without giving credit to the effort taken, putting you in the right direction... that is why I object to you closure

    I am sorry If I was not clear. The other approach I talked about is we are looking for plugins which I think I found as a wordpress plugin. As this was taking up too much time and my boss wants its done ASAP. I also awarded you points to you, because you were the only who replied. We are working to see if we create the same functionality in wordpress, so if that works out, I will surely post it here. Sorry for the confusion if any.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    I recently rediscovered rails when I needed a holiday project and decided to build a management dashboard for the company where I work.  With it being a project done in my free time, I could focus my time on learning the basics rather than trying to…
    WHY MVC is the future technology... As many of you know, MVC is Model,View,Controller pattern. Model View Controller pattern was invented in a Smalltalk context at Xerox in late 1970s. Why is this buzz about MVC: --------------------------- …
    The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now