Created
July 30, 2012 18:54
-
-
Save jonpaul/3209145 to your computer and use it in GitHub Desktop.
sr3 permalinks as attachments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# gets permalink for file on s3 | |
# | |
# *Parameters:* | |
# (+String+) -- aws_path full path of key to be uploaded to AWS (usually generated) | |
# | |
# *Returns:* | |
# (+String+) -- url | |
def self.get_permalink(aws_path, content_type = nil, content_disposition = nil) | |
return nil if aws_path.blank? | |
s3 = AWS::S3.new | |
b = s3.buckets[@bucket] | |
# b = s3.buckets.create(@bucket) | |
o = b.objects[aws_path] | |
return o.url_for(:read, :expires => 24.hours, :response_content_type => content_type, :response_content_disposition => content_disposition).to_s | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
def download
@attachment = Attachment.find(params[:id])
redirect_to @attachment.resource.expiring_url(10)
end