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:

ruby
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']
end

In 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

Your files are served from 450+ edge locations worldwide.

Edge-cached worldwide

Files are cached close to your users for fast delivery.

Signed-URL security

Private files stay protected with time-limited access.

What You Get

Unlimited files

Upload as many files as you need.

Unlimited storage

There is no storage limit.

Public + Private storage

Private files are fully secured.

CDN ready links

Upload directly to 450+ edge locations worldwide.

Prepaid credits

No subscription. Pay only for the storage and bandwidth you use.

More coming soon

We have plenty of features coming!

How files.link Works

1. Upload

Create a project and upload your first file.

2. Copy

Copy the CDN link.

3. Use Anywhere

Paste and enjoy the blazing speed.

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

0GB

Egress

0GB

CDN Bandwidth

0GB
Total: $0.000/month

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
Start Uploading from Ruby

Frequently Asked Questions

Do I need the aws-sdk-ruby gem?
No. The whole upload is three HTTP calls you can make with stdlib net/http, HTTParty, or Faraday. There is no SDK, no SigV4 signing, and nothing to add to your Gemfile.
How do I PUT binary data with net/http?
Open an SSL connection to the presigned URL host and call send_request('PUT', path, File.binread(path)). net/http reads the file into the request body without any multipart encoding — the presigned PUT expects raw bytes, not a form.
Where should the API key live?
Read it from ENV['FILESLINK_KEY'] or Rails encrypted credentials. Pass it as the raw value in the Authorization header — files.link does not use a Bearer prefix.
What comes back after confirm-upload?
Once you POST {ids:[id]} to /v1/files/confirm-upload the file goes live and you get a CDN URL you can store and serve. Public files resolve directly; private files are served through short-lived signed URLs.
How do I upload files larger than 100MB?
Use the multipart endpoint instead of a single presigned PUT. net/http streams each part from disk with File.binread offsets, so you never load a multi-gigabyte file fully into memory.
General Questions
Is there a subscription?
No. files.link uses prepaid credits, so storage, bandwidth, and API usage are deducted from your balance as you go. The app explains the payment step before uploads are enabled — no monthly subscription and no per-user fees.
What is files.link?
files.link is a developer-first file platform that makes it simple to store, secure, and deliver files globally. It provides signed URLs, public/private access, and an API-first design so you can integrate file delivery into any app without the usual complexity.
How does billing work?
files.link uses prepaid credits. As you use storage, bandwidth, and API requests, credits are deducted daily. When your balance runs low, we automatically recharge it using your saved card. If an auto-recharge doesn't go through, your files and links stay put — you simply update your payment method or top up manually to keep going. No monthly subscriptions — just simple usage-based pricing.
How secure is my data?
All files are encrypted at rest and in transit. You can use signed URLs for private files, control access with permissions, and rely on enterprise-grade infrastructure for data protection.

Related

files.link
Copyright © 2026
All rights reserved
ContactGuidesGlossaryStatusLegal