Skip to content

Instantly share code, notes, and snippets.

@mirakui mirakui/README.md
Last active Dec 20, 2015

Embed
What would you like to do?
fake-s3 + aws-sdk
$ gem install aws-sdk fake-s3
$ fakes3 -r /tmp/fakes3 -p 4567
Loading FakeS3 with /tmp/fakes3 on port 4567 with hostname s3.amazonaws.com
[2013-07-31 17:52:34] INFO  WEBrick 1.3.1
[2013-07-31 17:52:34] INFO  ruby 2.0.0 (2013-06-27) [x86_64-darwin12.4.0]
[2013-07-31 17:52:34] INFO  WEBrick::HTTPServer#start: pid=34539 port=4567
$ irb -r aws-sdk
> s3 = AWS::S3.new s3_endpoint: 'localhost', s3_port: 4567, s3_force_path_style: true, use_ssl: false
=> <AWS::S3>
> s3.buckets.create 'foo'
=> #<AWS::S3::Bucket:foo>
> s3.buckets['foo'].objects['obj1'].write 'test'
=> <AWS::S3::S3Object:foo/obj1>
> s3.buckets['foo'].objects['obj1'].read
=> "test"
localhost - - [31/Jul/2013:17:52:57 JST] "PUT /foo HTTP/1.1" 200 0
- -> /foo
localhost - - [31/Jul/2013:17:54:22 JST] "PUT /foo/obj1 HTTP/1.1" 200 0
- -> /foo/obj1
localhost - - [31/Jul/2013:17:54:29 JST] "GET /foo/obj1 HTTP/1.1" 200 4
- -> /foo/obj1
$ find /tmp/fakes3/foo
/tmp/fakes3/foo/obj1
/tmp/fakes3/foo/obj1/.fakes3_metadataFFF
/tmp/fakes3/foo/obj1/.fakes3_metadataFFF/content
/tmp/fakes3/foo/obj1/.fakes3_metadataFFF/metadata
$ cat /tmp/fakes3/foo/obj1/.fakes3_metadataFFF/content
test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.