Can I use send_file to send a file on a drive other than the Rails.root drive? I’ve tried both options below. I need to use the second option but Rails doesn’t like using a drive other than the volume on which it is on.
This works:
def action
send_file "C:\\rails_root\\public\\files\\file.ext"
end
This doesn’t:
def action
send_file "D:\\files\\file.ext"
end
Is send_file restricted to just the Rails.root drive? Is it possible to serve static files from a directory on a network mapped drive? Oh, and this is (un)fortunately an all windows environment.
UPDATE: So I’ve been digging around in the Rails/Ruby code that send_file uses and I think the primary culprit here is File.file?(path). It returns true when on the drive which Rails lives but false for networked drives.
UPDATE 2: Really strange. In the console both locations inserted for File.file?(path) return true. In the application running in the browser it returns false. I’m stumped.
It turns out that the service running Apache didn’t have permissions to access the network share.
In the controller I ended up using the direct network share address instead of using the mapped drive. I’m still not sure why the mapped drive didn’t work.
In the Apache configuration file (domain.conf) you have to use forward slashes when setting the parameters for XSendFile.
If anyone else has issues I’ll be glad to try and help.