fireimg
Ruby client for FireImg: API-key uploads, optional moderation, and CDN URLs.
Source of truth is developed in the private FireImg repo and mirrored here.
Install
gem 'fireimg', '~> 1.1'
bundle add fireimg
Configure
Fireimg.configure do |c|
c.api_key = ENV.fetch('FIREIMG_API_KEY')
c.project = ENV.fetch('FIREIMG_PROJECT')
c.api_base = ENV.fetch('FIREIMG_API_BASE', 'https://api.fireimg.com')
c.cdn_base = ENV.fetch('FIREIMG_CDN_BASE', 'https://img.fireimg.com')
end
FIREIMG_API_KEY and FIREIMG_PROJECT are also read automatically if you skip
the block. FIREIMG_API_BASE and FIREIMG_CDN_BASE have the defaults above.
Upload
Fireimg.upload does both steps the CLI does: request a presigned URL, then
PUT the bytes.
result = Fireimg.upload(
filename: 'feed_items/43/uuid.jpg',
content_type: 'image/jpeg',
path: '/tmp/photo.jpg', # or io: / body:
sizes: [
{ width: 800, quality: 'medium', fmt: 'webp' },
{ width: 160, height: 160, fit: 'cover', pos: 'center', fmt: 'webp' }
]
)
result.image_key # => "feed_items/43/uuid.jpg"
result.cdn_url # => "https://img.fireimg.com/{project}/images/feed_items/43/uuid.jpg"
filename may include folders. Provide the bytes with path:, io:, or
body:. Optional sizes (up to 20) are generated asynchronously after the
PUT and replace the project's default image params for that upload. Omit
sizes to keep project defaults. Pass sizes: [] to pre-generate only
FireImg's 80px dashboard thumbnail.
Fireimg.upload_many(files:, sizes:) batches the same way as the CLI
(up to 20 files per presign request).
If the client PUTs directly (NeedApp native/web), use Fireimg.presign and
PUT to result.upload_url with the same Content-Type.
Moderate and delete
labels = Fireimg.moderate('feed_items/43/uuid.jpg')
Fireimg.delete('feed_items/43/uuid.jpg')
Moderation returns FireImg labels; your app applies policy.
URLs
Fireimg.public_url('feed_items/43/uuid.jpg')
# => https://img.fireimg.com/{project}/images/feed_items/43/uuid.jpg
Fireimg.url('feed_items/43/uuid.jpg', width: 800, quality: 'medium', fmt: 'webp')
# => …/images/feed_items/43/uuid.jpg?width=800&quality=medium&fmt=webp
License
MIT