- Ruby

Learn how to configure for use with Filebase.

What is is a cloud services library for Ruby. allows you to seamlessly integrate your cloud configuration into your Ruby application.

Read below to learn how to use with Filebase.


1. Install

gem install fog

2. Download and install the fog-aws package:

gem install fog-aws

3. Create the file ~/.fog with the following content:

	aws_access_key_id:     <YOUR_FILEBASE_ACCESS_KEY>
	aws_secret_access_key: <YOUR_FILEBASE_SECRET_ACCESS_KEY>

4. In your Ruby application, add fog-aws as a dependency:

require 'fog/aws'

5. Connect to the Filebase S3 service:

s3 = 'AWS', region: 'us-east-1', bucket: ‘filebase-bucket’, host: ‘’)

Using Fog-AWS

Creating a file:

directory = 'directory-name')
file = directory.files.create(key: '/path/to/file-name, body:'file-name), tags: 'Org-Id=1&Service-Name=My-Service')

Listing files:

directory = s3.directories.get('directory-name', prefix: '/path/to')

Generating a Pre-signed URL for a file: '/path/to/file-name').url( + 60)

Copying a File to a Bucket

directory = 'directory-name')
file = directory.files.get('/path/to/file-name')
file.copy("target-bucket", "/path/to/copy-file-location")

Using Multipart Upload

To speed transfers of large files, the concurrency option can be used to spawn multiple threads. Note that the file must be at least 5 MB for multipart uploads to work. For example:

directory = 'directory-name')
file = directory.files.get('/path/to/file-name')
file.multipart_chunk_size = 10 * 1024 * 1024
file.concurrency = 10
file.copy("target-bucket", "/path/to/copy-file-location")

If you have any questions, please join our Discord server, or send us an email at

Last updated