Proxy S3 URL for uploaded assets

Is there any way to proxy the s3 url after a file has been uploaded? I’d like the URL for at least some of the assets that we upload to look like they come from our server rather than S3.

It would be nice for images on the site, but more important for generated files that we send to the user.

I’m sure that this has probably been answered before and has a simple answer, but I can’t seem to find it today.

Thanks!
-Chris

Something like this?

<%= link_to "here are the docs", @document %>

 # documents_controller.rb
 def show
    redirect_to @document.file.url
  end

Users won’t see it directly, will they?

That’s a good idea. I’ll have to take a look at that for the downloads of the generated items. It’s not as clean as I’d like it to be, but it’s not bad either.

I guess that’s kind of like sleight of hand. I guess I’m just surprised that there isn’t a plugin of some sort that would cache the file that’s on s3 and provide a local URL or something that would stream from the remote filestore and provide a local URL.

The reason that I’m doing this is that I’m moving to Heroku with no persistent storage from AWS where I have a lot of persistent storage, but lots of maintenance. Going S3 solves for the Heroku problem, but exposes the infrastructure.

Looking into things more, I wonder if “download_endpoint” plugin will help me. I’ll look and report back.

1 Like