FakeAWS
A minimal implementation of AWS as a Rack app, for testing and development.
This is designed to pair nicely with AWSRaw.
Installation
Add this line to your application's Gemfile:
gem 'fake_aws'
And then execute:
$ bundle
Or install it yourself as:
$ gem install fake_aws
So far there's only a tiny bit of S3 implemented, but it's well tested and fairly easy to extend. Pull requests for more features are welcome.
Usage
The easiest way to try this out is with Faraday:
connection = Faraday.new do |faraday|
faraday.adapter :rack, FakeAWS::S3::RackApp.new('root_directory')
end
The root directory you provide is used to store S3 objects and metadata.
For example, the following PUT Object request:
connection.put do |request|
request.url("http://s3.amazonaws.com/test_bucket/test_path/test_file.txt")
request.headers["Content-Type"] = "text/plain"
request.body = "Hello, world!"
end
will create a file root_directory/test_bucket/test_path/test_file.txt
.
It will also create
root_directory/test_bucket/test_path/test_file.txt.metadata.json
, which holds
the metadata for the file as a JSON hash.
Implemented Operations
S3
Path-style, virtual-hosted-style, and CNAME-style requests are supported for all operations.
No authentication or security is implemented.
Content-Type
and x-amz-metadata
headers are stored and returned.
Pull requests for other operations are welcome!
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
To Do
- Implement GET Bucket requests
- Improve the response headers (Content-Length, ETag, etc.)
- Check signing of requests
- Handle PUT Object Copy requests