Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Fake S3 Server For Local Development in Rails

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.33k
    Comment on it

    Fake S3 Server For Local Development in Rails

    Hi Friends,
    Once I was developing an application that includes accessing and saving the data to S3 buckets. But I didn't have any S3 account at that time, So I searched for a thing that can simulate an S3 environment in my local machine that can be helpful for the development enviroment and can also save the cost of storage of S3 bucket. I am a rails developer so I am much familiar with the aws-sdk gem for accessing to S3.
    After some effort, I got to know about a very lightweight gem fakes3, which can be used for running a fake s3 server on local machine. It also supports most of the basic commands like listing buckets, creating buckets, storing and reading contents, the best part is it supports the aws-sdk support and we don't need to change anything in our code for accessing this fake s3 server.
    To integrate fakes3 you first need to install fakes3 gem in your machine.

    gem install fakes3

    Now to run the server you need hit this command with any port and root you wish:

    fakes3 -r /mnt/fakes3_root -p 4567

    Now to connect to this S3 there are multiple ways like: In Ruby using AWS-S3:

           :access_key_id => "ACCESS_KEY_ID",
           :secret_access_key => "SECRET_ACCESS_KEY",
           :server => "localhost",
           :port => "4567" )

    In Ruby using AWS-SDK:
        :access_key_id => 'ACCESS_KEY_ID',
        :secret_access_key => 'SECRET_ACCESS_KEY',
        :s3_endpoint => 'localhost',
        :s3_port => 4567,
        :use_ssl => false )

    In Ruby using AWS-SDK v2:
        :access_key_id => 'ACCESS_KEY_ID',
        :secret_access_key => 'SECRET_ACCESS_KEY',
        :region => 'REGION',
        :endpoint => 'http://localhost:4567/',
        :force_path_style => true)

    So just you need to specify the port number on which correct s3 server is running and you will be connected to local s3 server to store, retrive, create buckets and data.
    It also supports for other clients like Java, Android, s3cmd, node js. You can see the list here:

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: