For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Dashboard
GuidesIntegrationsAPI ReferencesRelease notes
GuidesIntegrationsAPI ReferencesRelease notes
    • All integrations
  • Receiving files
    • Framework integrations
    • JavaScript File Uploader
    • React File Uploader
    • Angular File Uploader
    • Vue File Uploader
    • Svelte File Uploader
    • Next.js File Uploader
    • iOS
    • Android
    • CKEditor
    • TinyMCE
    • Redactor
    • Webflow
    • WordPress
    • Contentful CMS
    • JotForm
    • Marketo
  • Managing files
    • JavaScript SDK
    • PHP SDK
    • Python SDK
    • Ruby SDK
    • Rails SDK
    • Java SDK
    • Golang SDK
    • Rust SDK
    • Swift SDK
    • Kotlin SDK
    • Zapier
    • Make
    • Integrately
    • CLI
  • Delivering files
    • Adaptive image component
    • Next.js image loader
    • NuxtImage
  • From community
    • Shopify
    • Shopify (Debut theme)
    • WooCommerce
    • PHP Transformation URLs generation
    • Laravel Flysystem driver
    • Unpic Universal CDN URL translator
    • C# SDK
    • Erlang SDK
    • Elixir SDK
    • Flutter SDK
Dashboard
LogoLogo
On this page
  • Features
  • Requirements
  • Install
  • Using Gemfile
  • Using command line
  • Usage
  • Configuration
  • Full documentation
Managing files

Ruby on Rails API client

Was this page helpful?
Previous

Java API Client

Next
Built with

Ruby on Rails integration handles uploads and file operations by wrapping uploadcare-ruby gem. It will let you use most of the Uploadcare features from within your Ruby on Rails app.

Gem →

GitHub →

Features

Gem features:

  • File uploader
  • Image processing
  • Uploadcare API interfaces

Uploading (Upload API):

  • Upload files from local storage and URLs (up to 5 TB)
  • Multipart uploading for large files
  • Uploading network to speed uploading jobs (like CDN)

File management (REST API):

  • Get file info and perform various operations (store/delete/copy) with them
  • Work with groups of files
  • Get info about account project
  • Manage webhooks
  • Convert documents
  • Encode and transform videos

Image processing (URL API):

  • Compression
  • Geometry
  • Colors
  • Definition
  • Image and text overlays
  • Rotations
  • Recognition
  • File info
  • Proxy (fetch)

Security features:

  • Secure authentication
  • Secure uploads (signed uploads)
  • Secure delivery (signed URLs)
  • Secure webhooks (signing secret)

Requirements

  • Ruby 2.7+
  • Ruby on Rails 6.0+

Install

Using Gemfile

Add this line to your application’s Gemfile:

1gem "uploadcare-rails"

And then execute:

1bundle install

If you use api_struct gem in your project, replace it with uploadcare-api_struct:

gem 'uploadcare-api_struct'

and run bundle install.

Using command line

1gem install uploadcare-rails

Usage

Configuration

To start using Uploadcare API you just need to set your API keys (public key and secret key). These keys can be set as ENV variables using the export directive:

1export UPLOADCARE_PUBLIC_KEY=YOUR_PUBLIC_KEY
2export UPLOADCARE_SECRET_KEY=YOUR_SECRET_KEY

Or you can use popular gems like dotenv-rails for setting ENV variables. You must set the gem before uploadcare-rails like this:

gem "dotenv-rails", require: "dotenv/rails-now", groups: [:development, :test]
gem "uploadcare-rails"

Note: require: "dotenv/rails-now" is very important!

Run the config generator command to generate a configuration file:

1rails g uploadcare_config

The generator will create a new file in config/initializers/uploadcare.rb.

The public key must be specified in config/initializers/uploadcare.rb to use File Upload. This step is done automatically in the initializer if you set the ENV variable UPLOADCARE_PUBLIC_KEY earlier.

1...
2Uploadcare::Rails.configure do |config|
3 # Sets your Uploadcare public key.
4 config.public_key = ENV.fetch("UPLOADCARE_PUBLIC_KEY", "YOUR_PUBLIC_KEY")
5 ...
6end

There are also some options set by default:

1...
2# Deletes files from Uploadcare servers after object destroy.
3config.delete_files_after_destroy = true
4
5# Sets caching for Uploadcare files
6config.cache_files = true
7
8# Available locales currently are:
9# ar az ca cs da de el en es et fr he it ja ko lv nb nl pl pt ro ru sk sr sv tr uk vi zhTW zh
10config.locale = "en"
11
12# If true, inputs on your page are initialized automatically, see the article for details -
13# https://uploadcare.com/docs/file-uploader-api/widget-initialization/
14config.live = true
15
16# If true, input initialization is invoked manually.
17# See https://uploadcare.com/docs/file-uploader-api/widget-initialization/).
18config.manual_start = false

Then you can configure all global variables such as files storing/caching, deleting files, etc. Full list of available options is listed in the file itself. Just uncomment an option and set the value.

Full documentation

Read the full documentation on GitHub.