Send a file, is it possible to do something like this?

Hi, i’ve servers (not connected directly, only by internet), one with a
rails app, and another with the big static files. The problem is, to
access to one of them file you have to be logged, and when you click on
a link the rails app will send you the file, but using the other server.
Something like a redirect to download a file, but the real url of the
file shouldn’t be displayed.

Simple example:
I’m the user, i go to the site. I try to insert the url like
domain.com/download/3 and the rails app tell me that i have to login, i
login, i try another time and the app send me the file xyz.zip. Now,
because i’m curious i do a properties on the current download to show
where the file is stored, and i see domain.com/download/3, and not the
real one which would be domain2.com/files/xyz.com

What do you think? Is it possible ? There is send_file, but iirc it’s
just for local files.
Thanks

On 15 May 2008, at 10:35, Xdmx X. wrote:

What do you think? Is it possible ? There is send_file, but iirc it’s
just for local files.

The browser has to know where to get the file from or else it can’t
get it. I don’t think you can do this if the 2 servers are distinct
(and don’t have any shared storage) unless you do something horrible
like download it from the second server & forward it on byte by byte.

Fred

I’ve just recently done something like this, without the having to log
in.

I’ve created a downloads controller and a download model, the download
model
keeps track of what files are assigned to what IP and the users have to
use
the generated URL to get to their download. The cool thing is that it
will
not show the name of the file.

I’m using xsendfile to do this and going through apache. Another great
thing
is that, unlike send_file, this won’t tie up a Rails request. Very handy
if
you’re downloading large files.

Here’s something that may get you going:

http://john.guen.in/past/2007/4/17/send_files_faster_with_xsendfile/

On 15 May 2008, at 22:54, Ryan B. (Radar) wrote:

request. Very handy if you’re downloading large files.

Here’s something that may get you going:

http://john.guen.in/past/2007/4/17/send_files_faster_with_xsendfile/

The problem as i understand it is that the server with the files and
the server with the rails app are physically distinct, so send_file
XSendfile doesn’t help.

Fred

Frederick C. wrote:

The problem as i understand it is that the server with the files and
the server with the rails app are physically distinct, so send_file
XSendfile doesn’t help.

right, the server aren’t even in the same data center. i’ll hope in the
future to move everything in the same one so i’ll use xsendfile :slight_smile:
Thanks anyway :slight_smile:

Oh foo I didn’t see that in the first line.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs