I want to use local files stored under my server (not in Rails' public directory or in the project directory) just like the public folder.
For a more brief explanation, I have an /home/server/img
folder and my Rails project's root is something different. I want to be able to use these folder named "img" contents in my Rails app's, just like a resource file.
As an example;
<img src="/home/server/img">
I am using nginx to serve my app. And the img folder is mounted samba share directory. Thanks.
I found the solution to the question I asked earlier. Thing I was looking for was, I wanted to use local files under my webserver on my Rails application. The main idea behind this is I didn't want to fill my web server's storage space with user content.
Therefore I basically created a mounted share under my server with the following script, then used Rails's File.open
method in order to access this mounted directory's content.
The following functio reads the data from my UNIX based server's any directory and then sends the file to client machine with a basic HTTP communication. I placed this lines under controller function and gave a get routing under config/routes.rb
data_file = '/path/to/file'
data = File.open(File.expand_path(data_file), 'r')
send_data data.read, filename: "imageName.png", type: "image/png", disposition: 'inline', stream: 'true', buffer_size: '4096'
Here is another source explaining an answer for similar question.