Skip to content

Instantly share code, notes, and snippets.

@ktopping
Last active December 1, 2016 14:55
Show Gist options
  • Save ktopping/4762011 to your computer and use it in GitHub Desktop.
Save ktopping/4762011 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