Skip to content

Instantly share code, notes, and snippets.

@eprothro
Created March 10, 2017 23:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eprothro/f615b1b35186ce958b5dc7f5635283d1 to your computer and use it in GitHub Desktop.
Save eprothro/f615b1b35186ce958b5dc7f5635283d1 to your computer and use it in GitHub Desktop.
module S3DirectUploading
extend ActiveSupport::Concern
included do
S3_UPLOAD_BUCKET = Aws::S3::Resource.new.bucket(ENV['S3_UPLOAD_BUCKET'])
helper_method :build_s3_direct_post
end
protected
def build_s3_direct_post
S3_UPLOAD_BUCKET.presigned_post(key: "web_uploads/#{SecureRandom.uuid}/${filename}",
success_action_status: '201',
acl: 'public-read',
content_type_starts_with: "")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment