Last active
September 16, 2018 14:17
-
-
Save hasham2/8d424488932ac4360f0f to your computer and use it in GitHub Desktop.
Create s3 bucket and set CORS with Fog
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
| # this goes into config/initializers/fog.rb | |
| CONN = Fog::Storage.new({ | |
| :provider => 'AWS', | |
| :aws_access_key_id => 'ACCESS_KEY', | |
| :aws_secret_access_key => 'SECRET_KEY_HERE' | |
| }) |
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 User < ActiveRecord::Base | |
| # All other code goes here | |
| after_create :post_signup | |
| def post_signip | |
| CONN.put_bucket_cors 'newbucketname' | |
| CONN.put_bucket_cors 'newbucketname', {"CORSConfiguration" => [{"AllowedOrigin" => ["*"],"AllowedHeader" => ["Content-Length", "X-Foobar"],"AllowedMethod" => ["PUT", "GET"],"MaxAgeSeconds" => 3000,"ExposeHeader" => ["x-amz-server-side-encryption", "x-amz-balls"]}]} | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment