Ruby File Upload
Upload Files from Ruby Using net/http (No Gem Required)
Upload files from Ruby with net/http. No SDK, REST API, CDN delivery, prepaid credits.
Ruby ships with everything you need to upload a file to files.link: the net/http standard library handles JSON requests and raw binary PUTs without installing a single gem. That matters when you are running inside a slim container, a Lambda layer, or a CLI tool where every dependency you add to the Gemfile is weight you carry forever. The aws-sdk-s3 gem pulls in aws-sdk-core, aws-sigv4, jmespath and a chain of transitive dependencies just to sign a request; files.link replaces all of that with three plain HTTP calls.
The flow is identical across every Ruby HTTP client. Step one, POST your file metadata (name, size, type) to POST /v1/files/{folderId} with the raw API key in the Authorization header — no Bearer prefix. The response is { success: true, urls: [{ url, id, ... }] }, where url is a short-lived presigned PUT target. Step two, PUT the raw file bytes to that url. Step three, POST { ids: [id] } to /v1/files/confirm-upload to finalize the object and make its CDN link live.
With stdlib net/http it looks like this:
require 'net/http'
require 'json'
KEY = ENV.fetch('FILESLINK_KEY')
BASE = 'https://api.files.link'
def upload(folder_id, path)
meta = { filesMetadata: [{ name: File.basename(path), size: File.size(path), type: 'image/png' }] }
res = Net::HTTP.post(URI("#{BASE}/v1/files/#{folder_id}"),
meta.to_json, 'Authorization' => KEY, 'Content-Type' => 'application/json')
slot = JSON.parse(res.body)['urls'].first
put = Net::HTTP.new(URI(slot['url']).host, 443); put.use_ssl = true
put.send_request('PUT', URI(slot['url']).request_uri, File.binread(path), 'Content-Type' => 'image/png')
Net::HTTP.post(URI("#{BASE}/v1/files/confirm-upload"),
{ ids: [slot['id']] }.to_json, 'Authorization' => KEY, 'Content-Type' => 'application/json')
slot['id']
endIn a Rails app the same three calls drop cleanly into an ActiveJob or Sidekiq worker, so a controller can accept the upload, enqueue the transfer, and return immediately instead of blocking the request on a slow PUT. Because net/http is part of the standard library, this also runs unchanged in a bare Ruby script, a Sinatra endpoint, or a Jekyll build hook without touching the Gemfile.
Prefer HTTParty or Faraday? The same three calls map one-to-one — only the syntax changes. files.link returns a public CDN URL or a signed URL per file, so you decide visibility per object rather than per bucket. Storage is encrypted at rest and billed against prepaid credits, so a runaway upload script can never produce a five-figure surprise invoice.
Benefits With No Complexity
Global CDN delivery
Edge-cached worldwide
Signed-URL security
What You Get
Unlimited files
Unlimited storage
Public + Private storage
CDN ready links
Prepaid credits
More coming soon
How files.link Works
1. Upload
2. Copy
3. Use Anywhere
Why Developers Choose files.link
A Better Way to Store & Deliver Files
| AWS S3 (aws-sdk-ruby) | Cloudinary (cloudinary gem) | files.link | |
|---|---|---|---|
| Works with stdlib net/http (zero gems) | |||
| No SigV4 request signing to implement | |||
| Global CDN delivery on every file | |||
| Per-file public vs signed visibility | |||
| Prepaid credits (no surprise bills) |
Calculate Your Needs
Storage
Egress
CDN Bandwidth
Upload Files from Ruby
- Global CDN delivery
- Edge-cached worldwide
- Signed-URL security
- Unlimited files
- Unlimited storage
- Public + Private storage
- No subscription — prepaid credits keep spend predictable