Ruby on Rails API client
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.
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:
And then execute:
If you use api_struct
gem in your project, replace it with uploadcare-api_struct
:
and run bundle install
.
Using command line
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:
Or you can use popular gems like dotenv-rails
for setting ENV variables.
You must set the gem before uploadcare-rails
like this:
Note: require: "dotenv/rails-now"
is very important!
Run the config generator command to generate a configuration file:
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.
There are also some options set by default:
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.