Last active
October 2, 2016 17:10
-
-
Save danielwestendorf/2a42ee25074e99020eca7870886116c0 to your computer and use it in GitHub Desktop.
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
class Upload < ApplicationRecord | |
validates :size, inclusion: { in: 0..2.megabytes } | |
def key | |
"#{id}/#{filename}" | |
end | |
def url | |
bucket.object(key).presigned_url(:get, expires_in: 604_800) | |
end | |
def bucket | |
@bucket ||= Aws::S3::Resource.new.bucket(ENV["AWS_S3_BUCKET"]) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment