Created
February 27, 2020 01:29
-
-
Save nikasulo/0ae8234ec2c86cedff8d8cf59071566d to your computer and use it in GitHub Desktop.
This file contains 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 S3UploadsController < ApplicationController | |
def set_s3_direct_post | |
filename = params[:filename] | |
file_type = params[:fileType] | |
directory = params[:directory] | |
random_path = SecureRandom.uuid | |
key = "uploads/#{directory}/#{random_path}/#{filename}" | |
signer = Aws::S3::Presigner.new | |
post_url = signer.presigned_url(:put_object, bucket: "damilare-api", key: key, acl: 'public-read', content_type: file_type) | |
get_url = "https://damilare-api.s3-us-west-1.amazonaws.com/#{key}" | |
json_response( | |
{ | |
post_url: post_url, | |
get_url: get_url, | |
} | |
) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment