Skip to content

Instantly share code, notes, and snippets.

@ppicazo
Forked from ktopping/fake-s3-config.rb
Created May 12, 2016 23:17
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 ppicazo/53753f725369d7441a7d9435f9e257e5 to your computer and use it in GitHub Desktop.
Save ppicazo/53753f725369d7441a7d9435f9e257e5 to your computer and use it in GitHub Desktop.
fake s3 config
# Add the following to /etc/hosts:
127.0.0.1 local.s3.endpoint local-bucket.local.s3.endpoint
# Run the following in your rails console, in order to create a bucket:
s3=AWS::S3.new(
:access_key_id => 'anything',
:secret_access_key => 'anything',
:s3_endpoint => 'local.s3.endpoint',
:s3_port => 4567,
:use_ssl => false
)
s3.buckets.create('local-bucket')
# Then configure paperclip as usual, but adding the following config to has_attached_file:
...
:s3_credentials => {
:access_key_id => "anything",
:secret_access_key => "anything"
},
:bucket => "local-bucket",
:s3_host_name => "local.s3.endpoint",
:url => ":s3_alias_url", # because I can't work out any other way of getting the port in there with Paperclip 2.7.4!
:s3_host_alias => "local-bucket.local.s3.endpoint:4567", # because I can't work out any other way of getting the port in there with Paperclip 2.7.4!
:s3_options => {
:use_ssl => false,
:s3_port => 4567
}
...
# I run fake-s3 as follows:
fakes3 -r /path/to/directory -p 4567 >log/fakes3.log 2>&1 &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment