I have a simple app in Rails which allows me to upload file to Amazon S3 by using Carrierwave and fog. It works fine. I'm now working on downloading the files and display them on the browser. It works. However, the private link (which I set it to be a temporary link) from S3 is shown on browser, like:
I don't want to expose the private link from S3. Instead, I wish the link like below is shown: www.xxx.com/user/1/resume/1
I have a model resume.rb
class Resume < ActiveRecord::Base
mount_uploader :attachment, ResumeUploader
end
Controller with show action
def show
@resume = Resume.find(params[:id])
@resume_name = @resume.attachment.path.split("/").last
end
And my view: show.html.erb
<%= link_to @resume_name, @resume.attachment.url %>
I'm new to the ROR. Could anyone please tell me how can I show the file on the browser without showing the private url from S3?
You can route your images through CloudFront. Cloud Front has many advantages but it does comes at a cost. Once you route your images through cloud front you get a domain kind of link for your assets same as s3 does, but in cloudfront you can change the link.