Fog.io - Ruby
Learn how to configure Fog.io for use with Filebase.
gem install fog
gem install fog-aws
default:
aws_access_key_id: <YOUR_FILEBASE_ACCESS_KEY>
aws_secret_access_key: <YOUR_FILEBASE_SECRET_ACCESS_KEY>
require 'fog/aws'
s3 = Fog::Storage.new(provider: 'AWS', region: 'us-east-1', bucket: ‘filebase-bucket’, host: ‘s3.filebase.com’)
directory = s3.directories.new(key: 'directory-name')
file = directory.files.create(key: '/path/to/file-name, body: File.open('file-name), tags: 'Org-Id=1&Service-Name=My-Service')
directory = s3.directories.get('directory-name', prefix: '/path/to')
directory.files
directory.files.new(key: '/path/to/file-name').url(Time.now + 60)
directory = s3.directories.new(key: 'directory-name')
file = directory.files.get('/path/to/file-name')
file.copy("target-bucket", "/path/to/copy-file-location")
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 = s3.directories.new(key: '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 [email protected]
Last modified 1yr ago