{"id":13879809,"url":"https://github.com/uploadcare/uploadcare-rails","last_synced_at":"2025-05-16T01:04:12.116Z","repository":{"id":5254336,"uuid":"6432090","full_name":"uploadcare/uploadcare-rails","owner":"uploadcare","description":"Rails API client that handles uploads and further operations with files by wrapping Uploadcare Upload and REST APIs.","archived":false,"fork":false,"pushed_at":"2024-11-07T17:56:43.000Z","size":2120,"stargazers_count":58,"open_issues_count":2,"forks_count":71,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-05-10T06:07:58.052Z","etag":null,"topics":["cdn","image-processing","ruby","ruby-on-rails","upload","upload-images","upload-pictures","upload-videos","uploadcare","uploading","widget"],"latest_commit_sha":null,"homepage":"https://uploadcare.com","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"card-io/card.io-iOS-source","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uploadcare.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-10-28T21:08:43.000Z","updated_at":"2024-11-07T17:32:01.000Z","dependencies_parsed_at":"2024-06-01T18:53:18.063Z","dependency_job_id":"c3d096b8-875c-4204-b51d-12352a461178","html_url":"https://github.com/uploadcare/uploadcare-rails","commit_stats":{"total_commits":49,"total_committers":10,"mean_commits":4.9,"dds":0.7551020408163265,"last_synced_commit":"cbf92458e21539b3fcbd8b3b09fc68d27a72c221"},"previous_names":[],"tags_count":42,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uploadcare%2Fuploadcare-rails","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uploadcare%2Fuploadcare-rails/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uploadcare%2Fuploadcare-rails/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uploadcare%2Fuploadcare-rails/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uploadcare","download_url":"https://codeload.github.com/uploadcare/uploadcare-rails/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254448579,"owners_count":22072764,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cdn","image-processing","ruby","ruby-on-rails","upload","upload-images","upload-pictures","upload-videos","uploadcare","uploading","widget"],"created_at":"2024-08-06T08:02:34.154Z","updated_at":"2025-05-16T01:04:12.085Z","avatar_url":"https://github.com/uploadcare.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# Uploadcare Rails\n\n![license](https://img.shields.io/badge/license-MIT-brightgreen.svg)\n[![Build Status][actions-img]][actions-badge]\n\n[actions-badge]: https://github.com/uploadcare/uploadcare-rails/actions/workflows/test.yml\n[actions-img]: https://github.com/uploadcare/uploadcare-rails/actions/workflows/test.yml/badge.svg\n\nA Ruby on Rails plugin for [Uploadcare](https://uploadcare.com) service.\nBased on [uploadcare-ruby](https://github.com/uploadcare/uploadcare-ruby) gem (general purpose wrapper for Uploadcare API)\n\n:heavy_exclamation_mark: *Note: the gem uploadcare-rails 2.x is not backward compatible with 1.x.*\n\n## Table of Contents\n\n* [Requirements](#requirements)\n* [Installation](#installation)\n  * [Using Gemfile](#using-gemfile)\n  * [Using command line](#using-command-line)\n* [Usage](#usage)\n  * [Configuration](#configuration)\n  * [Uploadcare File Uploader](#uploadcare-file-uploader)\n    * [Widget](#widget)\n      * [Using CDN](#using-cdn)\n      * [Using NPM](#using-npm)\n    * [Input](#input)\n  * [Using the File Uploader with Rails models](#using-the-file-uploader-with-rails-models)\n    * [Form data](#form-data)\n    * [File and Group wrappers](#file-and-group-wrappers)\n  * [Image Transformation](#image-transformation)\n  * [Uploadcare API interfaces](#uploadcare-api-interfaces)\n    * [Upload Api](#upload-api)\n    * [File Api](#file-api)\n    * [Group Api](#group-api)\n    * [Project Api](#project-api)\n    * [Webhook Api](#webhook-api)\n    * [Conversion Api](#conversion-api)\n    * [File Metadata Api](#file-metadata-api)\n    * [Add-Ons Api](#add-ons-api)\n* [Useful links](#useful-links)\n\n## Requirements\n* ruby 2.7+\n* Ruby on Rails 6.0+\n\n## Installation\n\n### Using Gemfile\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem \"uploadcare-rails\"\n```\n\nAnd then execute:\n\n```console\n$ bundle install\n```\n\nIf you use `api_struct` gem in your project, replace it with `uploadcare-api_struct`:\n```ruby\ngem 'uploadcare-api_struct'\n```\nand run `bundle install`\n\n### Using command line\n\n```console\n$ gem install uploadcare-rails\n```\n\n## Usage\n\n### Configuration\n\nTo start using Uploadcare API you just need to set your [API keys](https://app.uploadcare.com/projects/-/api-keys/) (public key and secret key).\nThese keys can be set as ENV variables using the `export` directive:\n\n```console\n$ export UPLOADCARE_PUBLIC_KEY=your_public_key\n$ export UPLOADCARE_SECRET_KEY=your_private_key\n```\nOr you can use popular gems like `dotenv-rails` for setting ENV variables.\nYou must set the gem before `uploadcare-rails` like this :\n```ruby\ngem \"dotenv-rails\", require: \"dotenv/rails-now\", groups: [:development, :test]\ngem \"uploadcare-rails\"\n```\n:warning: `require: \"dotenv/rails-now\"` is very important!\n\nRun the config generator command to generate a configuration file:\n\n```console\n$ rails g uploadcare_config\n```\n\nThe generator will create a new file in `config/initializers/uploadcare.rb`.\n\nThe public key must be specified in `config/initializers/uploadcare.rb` to use Uploadcare file upload.\nThis step is done automatically in the initializer if you set the ENV variable `UPLOADCARE_PUBLIC_KEY` earlier.\n\n```ruby\n...\nUploadcare::Rails.configure do |config|\n  # Sets your Uploadcare public key.\n  config.public_key = ENV.fetch(\"UPLOADCARE_PUBLIC_KEY\", \"your_public_key\")\n  ...\nend\n```\n\nThere are also some options set by default:\n\n```ruby\n...\n# Deletes files from Uploadcare servers after object destroy.\nconfig.delete_files_after_destroy = true\n\n# Sets caching for Uploadcare files\nconfig.cache_files = true\n\n# Available locales currently are:\n# 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\nconfig.locale = \"en\"\n\n# If true, inputs on your page are initialized automatically, see the article for details -\n# https://uploadcare.com/docs/file-uploader-api/widget-initialization/\nconfig.live = true\n\n# If true, input initialization is invoked manually.\n# See https://uploadcare.com/docs/file-uploader-api/widget-initialization/).\nconfig.manual_start = false\n```\n\nThen you can configure all global variables such as files storing/caching, deleting files, etc.\nFull list of available options is listed in the file itself. Just uncomment an option and set the value.\n\n\n### Uploadcare File Uploader\n\n### Widget\n\n#### Using CDN\n\nThe fastest way to start using file uploading is to add the Uploadcare widget to the html-page.\nThere is a view helper that can do it with two strings of code:\n\nAdd this string to your `\u003chead\u003e` html-tag\n\n```erb\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n  \u003ctitle\u003eRailsApp\u003c/title\u003e\n  \u003c%= uploadcare_include_tag %\u003e\n  \u003c!--\n    results in:\n    \u003cscript src=\"https://ucarecdn.com/libs/widget/3.x/uploadcare.full.min.js\"\u003e\u003c/script\u003e\n    \u003cscript\u003e\n      //\u003c![CDATA[\n      UPLOADCARE_PUBLIC_KEY = \"your_public_key\";\n      UPLOADCARE_LOCALE = \"en\";\n      UPLOADCARE_LIVE = true;\n      UPLOADCARE_MANUAL_START = false;\n      //]]\u003e\n    \u003c/script\u003e\n  --\u003e\n\u003c/head\u003e\n...\n```\nThis helper uses a CDN-url for the widget bundle and supports three options:\n\n- **version** — version of the Uploadcare widget. Default is \"3.x\".\n- **bundle** — bundle name. Available names are \"full\", \"default\", \"api\", \"ie8\" and \"lang.en\".\n               Default bundle is \"full\" — a full bundle with built-in jQuery.\n               More info about bundles [here](https://uploadcare.com/docs/uploads/file-uploader/#bundles).\n- **min** — bool value detecting if the bundle must be minified.\n\nThe `\u003chead\u003e` tag then also includes the `\u003cscript\u003e` with widget global settings set in `config/initializers/uploadcare.rb`. You can override them later in an individual widget.\n\n\n#### Using asset pipeline.\n\nDownload and append widget manually to your asset pipeline. You may download (e.g. https://ucarecdn.com/libs/widget/3.x/uploadcare.full.min.js) and serve the widget yourself along with your other assets.\n\n#### Using NPM\n\nInstalling via NPM instructions can be found [here](https://uploadcare.com/docs/uploads/file-uploader/#npm).\n\n### Input\n\nWhen the widget is on a html-page, you want to add an input to your view that will be used by the File Uploader:\n\n```erb\n...\n\u003c%= uploadcare_uploader_field :object, :attribute %\u003e\n\u003c!--\n  results in:\n  \u003cinput role=\"uploadcare-uploader\" type=\"hidden\" name=\"object[attribute]\" id=\"object_attribute\"\u003e\n--\u003e\n...\n```\n\n- **object** — object name;\n- **attribute** — object attribute name.\n\n### Using the File Uploader with Rails models\n\nView helpers are good to be used for Rails models.\nFirst, you need to mount uploadcare file or group to the model attribute.\nFor example you have a database table like this and model `Post`:\n```\n# DB table \"posts\"\n---------------------\ntitle       | String\n---------------------\npicture     | String\n---------------------\nattachments | String\n---------------------\n```\n\n### Form data\n\n#### Uploadcare File\n\n```ruby\n# app/models/post.rb\nclass Post \u003c ApplicationRecord\n  mount_uploadcare_file :picture\nend\n```\n\n```erb\n\u003c!-- app/views/posts/new.html.erb --\u003e\n\u003ch1\u003e NEW POST \u003c/h1\u003e\n\n\u003c%= form_tag(\"/posts\", method: :post) do %\u003e\n  \u003c%= uploadcare_uploader_field :post, :picture %\u003e\n  \u003c!--\n    results in:\n    \u003cinput role=\"uploadcare-uploader\" multiple=\"false\" type=\"hidden\" name=\"post[picture]\" id=\"post_picture\"\u003e\n  --\u003e\n  \u003cdiv\u003e\n    \u003c%= submit_tag \"Save\" %\u003e\n  \u003c/div\u003e\n\u003c% end %\u003e\n```\n\n#### Uploadcare File Group\n\n```ruby\n# app/models/post.rb\nclass Post \u003c ApplicationRecord\n  mount_uploadcare_file_group :attachments\nend\n```\n\n```erb\n\u003c!-- app/views/posts/new.html.erb --\u003e\n\u003ch1\u003e NEW POST \u003c/h1\u003e\n\n\u003c%= form_tag(\"/posts\", method: :post) do %\u003e\n  \u003c%= uploadcare_uploader_field :post, :attachments %\u003e\n  \u003c!--\n    results in:\n    \u003cinput role=\"uploadcare-uploader\" multiple=\"true\" type=\"hidden\" name=\"post[attachments]\" id=\"post_attachments\"\u003e\n  --\u003e\n  \u003cdiv\u003e\n    \u003c%= submit_tag \"Save\" %\u003e\n  \u003c/div\u003e\n\u003c% end %\u003e\n```\n\nThe input will have a `value` property set to CDN-urls when you will select files to upload in the widget.\n\n```erb\n\u003cinput role=\"uploadcare-uploader\" type=\"hidden\" name=\"post[picture]\" id=\"post_picture\" value=\"https://ucarecdn.com/8355c2c5-f108-4d74-963d-703d48020f83/\"\u003e\n```\n\nSo, you get CDN-urls as a value of the attribute in the controller on form submit.\nThe value will be available in the controller by `params[:post][:picture]`.\n\nThe helper is detecting the value of the `multiple` property based on the mount type in your model.\n\n### Caching issues with Turbolinks/Hotwire\n\nIf you are facing issue, with multiple input elements being rendered due to turbolinks caching you can append this fix in the `app/javascript/application.js` to overcome this:\n\n```\ndocument.addEventListener('turbolinks:before-cache', function() {\n    const dialogClose = document.querySelector('.uploadcare--dialog__close');\n    if (dialogClose) {\n        dialogClose.dispatchEvent(new Event('click'));\n    }\n\n    const dialog = document.querySelector('.uploadcare--dialog');\n    if (dialog) {\n        dialog.remove();\n    }\n\n    const widgets = document.querySelectorAll('.uploadcare--widget');\n    widgets.forEach(widget =\u003e {\n        widget.remove();\n    });\n});\n```\n\nSimilarly if you are using [Hotwire](https://hotwired.dev/) then use can you use below code:\n\n```\ndocument.addEventListener('turbo:before-cache', function() {\n    const dialogClose = document.querySelector('.uploadcare--dialog__close');\n    if (dialogClose) {\n        dialogClose.dispatchEvent(new Event('click'));\n    }\n\n    const dialog = document.querySelector('.uploadcare--dialog');\n    if (dialog) {\n        dialog.remove();\n    }\n\n    const widgets = document.querySelectorAll('.uploadcare--widget');\n    widgets.forEach(widget =\u003e {\n        widget.remove();\n    });\n});\n```\n\n### File and Group wrappers\n\nWhen you mount either Uploadcare File or Group to an attribute, this attribute is getting wrapped with\na Uploadcare object. This feature adds some useful methods to the attribute.\n\nNote: Supports ActiveRecord, ActiveModel and Mongoid models.\n\n#### Uploadcare File\n\nSay, you have such model in your Rails app:\n\n```ruby\n# app/models/post.rb\nclass Post \u003c ApplicationRecord\n  mount_uploadcare_file :picture\nend\n```\n\nAnd then you create a new Post object specifying a CDN-url for your previously uploaded Uploadcare file:\n\n```ruby\npost = Post.create(picture: \"https://ucarecdn.com/2d33999d-c74a-4ff9-99ea-abc23496b052/\")\n```\n\nNow the `post.picture` is an Uploadcare::Rails::File. Following methods are supported:\n\n```ruby\n# Store the file on an Uploadcare server permanently:\npost.picture.store\n#   =\u003e {\n#         \"cdn_url\"=\u003e\"https://ucarecdn.com/2d33999d-c74a-4ff9-99ea-abc23496b052/\",\n#          ...other group data...\n#      }\n\n#\n# Delete the file from an Uploadcare server permanently:\npost.picture.delete\n#   =\u003e {\n#         \"datetime_removed\"=\u003e\"2021-07-30T09:19:30.797174Z\",\n#          ...other group data...\n#      }\n\n# Get CDN-url of an object attribute:\npost.picture.to_s\n#   =\u003e \"https://ucarecdn.com/2d33999d-c74a-4ff9-99ea-abc23496b052/\"\n\n# Load object (send a GET request to the server to get all the file's data)\n# This data will be cached if the cache_files option is set to true\n# Default data (without asking an Uploadcare server) for each file contains cdn_url and uuid only:\npost.picture.load\n#   =\u003e {\n#         \"cdn_url\"=\u003e\"https://ucarecdn.com/2d33999d-c74a-4ff9-99ea-abc23496b052/\",\n#          ...other file data...\n#      }\n\n# Check if an attribute loaded from the server.\n# Will return false unless the :load or the :store methods are called:\npost.picture.loaded?\n#   =\u003e true\n\n# More about image transformations below.\n# Transform a CDN-url to get a new transformed image's source. Works for images only:\npost.picture.transform_url(quality: \"better\")\n#   =\u003e \"https://ucarecdn.com/2d33999d-c74a-4ff9-99ea-abc23496b052/-/quality/better/\"\n```\n\n#### Uploadcare File Group\n\nGroups work similar to the File but have some differences though.\n\n```ruby\n# app/models/post.rb\nclass Post \u003c ApplicationRecord\n  mount_uploadcare_file_group :attachments\nend\n```\n\nCreating a new `post` with the Group mounted:\n\n```ruby\npost = Post.create(attachments: \"https://ucarecdn.com/dbc4e868-b7a6-43ff-a35f-2ebef935dc1b~1/\")\n```\n\nNow the `post.attachments` is an Uploadcare::Rails::Group. Following methods are supported:\n\n```ruby\n# Store the file group on an Uploadcare server permanently:\npost.attachments.store\n#   =\u003e {\n#         \"cdn_url\"=\u003e\"https://ucarecdn.com/dbc4e868-b7a6-43ff-a35f-2ebef935dc1b~1/\",\n#          ...other group data...\n#         \"files\"=\u003e [{\n#            \"datetime_stored\"=\u003e\"2021-07-29T08:31:45.668354Z\",\n#            ...other file data...\n#         }]\n#      }\n\n#\n# Delete the file group from an Uploadcare server permanently:\npost.attachments.delete\n#   =\u003e {\n#         \"datetime_removed\"=\u003e\"2021-07-30T09:19:30.797174Z\",\n#          ...other group data...\n#      }\n\n# Get CDN-url of an object attribute:\npost.attachments.to_s\n#   =\u003e \"https://ucarecdn.com/dbc4e868-b7a6-43ff-a35f-2ebef935dc1b~1/\"\n\n# Load object — works the same way as for the File:\npost.attachments.load\n#   =\u003e {\n#         \"cdn_url\"=\u003e\"https://ucarecdn.com/dbc4e868-b7a6-43ff-a35f-2ebef935dc1b~1/\",\n#          ...other group data...\n#         \"files\"=\u003e [{\n#            \"datetime_stored\"=\u003e\"2021-07-29T08:31:45.668354Z\",\n#            ...other file data...\n#         }]\n#      }\n\n# Check if an attribute loaded from the server:\npost.attachments.loaded?\n#   =\u003e true\n\n# As we don't want to show (on the html-page) a file group itself,\n# we can get CDN-urls for file that the group contains. No loading group or files needed.\n# This works for images only:\npost.attachments.transform_file_urls(quality: \"better\")\n#   =\u003e [\"https://ucarecdn.com/dbc4e868-b7a6-43ff-a35f-2ebef935dc1b~1/nth/0/-/quality/better/\"]\n\n# If you want to get non-transformed file urls, use:\npost.attachments.file_urls\n#   =\u003e [\"https://ucarecdn.com/dbc4e868-b7a6-43ff-a35f-2ebef935dc1b~1/nth/0/\"]\n```\n\n\n### Image Transformation\n\nUploadcare provides a way to transform images stored on Uploadcare services specifying a list of operations.\nIf an operation has just one option, you can specify it like key-value:\n\n```ruby\npost.picture.transform_url(quality: \"better\")\n#   =\u003e \"https://ucarecdn.com/ebbb9929-eb92-4f52-a212-eecfdb19d27d/-/quality/better/\"\n```\n\nand if an operation supports several options — just set them as a Hash:\n\n```ruby\npost.picture.transform_url(crop: { dimensions: \"300x500\", coords: \"50, 50\", alignment: \"center\" })\n#   =\u003e \"https://ucarecdn.com/ebbb9929-eb92-4f52-a212-eecfdb19d27d/-/crop/300x500/50,50/center/\"\n```\n\nFull list of operations and valid values can be found [here](https://uploadcare.com/docs/transformations/image/).\n\n### Uploadcare API interfaces\n\nUploadcare provides [APIs](https://uploadcare.com/docs/start/api/) to manage files, group, projects, webhooks, video and documents conversion and file uploads. The gem has unified interfaces to use Uploadcare APIs in RailsApp.\n\n### Upload API\n\n[Upload Api](https://uploadcare.com/api-refs/upload-api/) provides methods to upload files in many ways.\n\n#### Upload a single file\n\n```ruby\n# Load a file\nfile = File.open(\"kitten.png\")\n#   =\u003e #\u003cFile:kitten.png\u003e\n\n# Upload file to Uploadcare\nuploadcare_file = Uploadcare::UploadApi.upload_file(file)\n#   =\u003e {\n#         \"uuid\"=\u003e\"2d33999d-c74a-4ff9-99ea-abc23496b053\",\n#          ...other file data...\n#      }\n```\n\nThis method supports single file uploading and uploading files from an URL (depending on the type of first argument - can be either String (i.e. URL) or File).\n\n```ruby\n# Upload file from URL\nurl = \"https://ucarecdn.com/80b807be-faad-4f01-bbbe-0bbde172b9de/1secVIDEO.mp4\"\nuploadcare_file = Uploadcare::UploadApi.upload_file(url)\n#   =\u003e [\n#        {\n#          \"size\"=\u003e22108,\n#          \"uuid\"=\u003e\"b5ed5e1d-a939-4fe4-bfb2-31d3867bb6s6\",\n#          \"original_filename\"=\u003e\"1 sec VIDEO.mp4\",\n#          \"is_image\"=\u003efalse,\n#          \"image_info\"=\u003enil,\n#          \"is_ready\"=\u003etrue,\n#          \"mime_type\"=\u003e\"video/mp4\"\n#        }\n#      ]\n```\n\n\n#### Upload several files\n\n```ruby\n# Load a file\nfile = File.open(\"kitten.png\")\n#   =\u003e #\u003cFile:kitten.png\u003e\n# Upload several files to Uploadcare\nuploadcare_file = Uploadcare::UploadApi.upload_files([file])\n#   =\u003e [\n#        {\n#          \"uuid\"=\u003e\"2dfc94e6-e74e-4014-9ff5-a71b8928f4fa\",\n#          \"original_filename\"=\u003e:\"kitten.png\"\n#        }\n#      ]\n```\n\n\n### File API\n\nFileApi provides an interface to manage single files, stored on Uploadcare Servers.\n\n#### Get files\n\n```ruby\n# Valid options:\n# removed: [true|false]\n# stored: [true|false]\n# limit: (1..1000)\n# ordering: [\"datetime_uploaded\"|\"-datetime_uploaded\"]\n# from: A starting point for filtering files. The value depends on your ordering parameter value.\nUploadcare::FileApi.get_files(ordering: \"datetime_uploaded\", limit: 10)\n#   =\u003e {\n#        \"next\"=\u003enil,\n#        \"previous\"=\u003enil,\n#        \"total\"=\u003e2,\n#        \"per_page\"=\u003e10,\n#        \"results\"=\u003e [\n#          {\n#            \"datetime_removed\"=\u003enil,\n#            ... file data ...\n#          }\n#        ]\n#      }\n```\n\n\n#### Get a file by UUID\n\n```ruby\n$ Uploadcare::FileApi.get_file(\"7b2b35b4-125b-4c1e-9305-12e8da8916eb\")\n#   =\u003e {\n#         \"cdn_url\"=\u003e\"https://ucarecdn.com/7b2b35b4-125b-4c1e-9305-12e8da8916eb/\",\n#          ...other file data...\n#      }\n```\n\n\n#### Copy a file to default storage. Source can be UID or full CDN link\n\n```ruby\n# Valid options:\n# stored: [true|false]\nUploadcare::FileApi.local_copy_file(\"2d33999d-c74a-4ff9-99ea-abc23496b052\", store: false)\n#   =\u003e {\n#         \"uuid\"=\u003e\"f486132c-2fa5-454e-9e70-93c5e01a7e04\",\n#          ...other file data...\n#      }\n```\n\n#### Copy a file to custom storage. Source can be UID or full CDN link\n\n```ruby\n# Valid options:\n# make_public: [true|false]\nUploadcare::FileApi.remote_copy_file(\"2d33999d-c74a-4ff9-99ea-abc23496b052\", \"mytarget\", make_public: false)\n#   =\u003e {\n#         \"uuid\"=\u003e\"f486132c-2fa5-454e-9e70-93c5e01a7e04\",\n#          ...other file data...\n#      }\n```\n\n\n#### Store a file by UUID\n\n```ruby\nUploadcare::FileApi.store_file(\"2d33999d-c74a-4ff9-99ea-abc23496b052\")\n#   =\u003e {\n#         \"uuid\"=\u003e\"2d33999d-c74a-4ff9-99ea-abc23496b052\",\n#          ...other file data...\n#      }\n```\n\n\n#### Store several files by UUIDs\n\n```ruby\nUploadcare::FileApi.store_files([\"f486132c-2fa5-454e-9e70-93c5e01a7e04\"])\n#   =\u003e {\n#        \"result\" =\u003e [\n#          {\n#            \"uuid\"=\u003e\"f486132c-2fa5-454e-9e70-93c5e01a7e04\",\n#            ...other file data...\n#          }\n#        ]\n#      }\n```\n\n\n#### Delete a file by UUID\n\n```ruby\nUploadcare::FileApi.delete_file(\"2d33999d-c74a-4ff9-99ea-abc23496b052\")\n#   =\u003e {\n#         \"uuid\"=\u003e\"2d33999d-c74a-4ff9-99ea-abc23496b052\",\n#          ...other file data...\n#      }\n```\n\n\n#### Delete several files by UUIDs\n\n```ruby\nUploadcare::FileApi.delete_files([\"f486132c-2fa5-454e-9e70-93c5e01a7e04\"])\n#   =\u003e {\n#        \"result\" =\u003e [\n#          {\n#            \"uuid\"=\u003e\"f486132c-2fa5-454e-9e70-93c5e01a7e04\",\n#            ...other file data...\n#          }\n#        ]\n#      }\n```\n\n\n### Group API\n\nGroupApi provides an interface to manage file groups stored on Uploadcare Servers.\n\n#### Get file groups\n\n```ruby\n# Valid options:\n# limit: (1..1000)\n# ordering: [\"datetime_created\"|\"-datetime_created\"]\n# from: A starting point for filtering group lists. MUST be a datetime value with T used as a separator.\n#   example: \"2015-01-02T10:00:00\"\nUploadcare::GroupApi.get_groups(ordering: \"datetime_uploaded\", limit: 10)\n#   =\u003e {\n#        \"next\"=\u003e\"next\"=\u003e\"https://api.uploadcare.com/groups/?ordering=datetime_uploaded\u0026limit=10\u0026from=2021-07-16T11%3A12%3A12.236280%2B00%3A00\u0026offset=0\",\n#        \"previous\"=\u003enil,\n#        \"total\"=\u003e82,\n#        \"per_page\"=\u003e10,\n#        \"results\"=\u003e [\n#          {\n#            \"id\"=\u003e\"d476f4c9-44a9-4670-88a5-c3cf5a26b6c2~20\",\n#            \"datetime_created\"=\u003e\"2021-07-16T11:03:01.182239Z\",\n#            \"datetime_stored\"=\u003enil,\n#            \"files_count\"=\u003e20,\n#            \"cdn_url\"=\u003e\"https://ucarecdn.com/d476f4c9-44a9-4670-88a5-c3cf5d16b6c2~20/\",\n#            \"url\"=\u003e\"https://api.uploadcare.com/groups/d476f4c9-44a9-4670-83a5-c3cf5d26b6c2~20/\"\n#          },\n#          ... other groups data ...\n#        ]\n#      }\n```\n\n\n#### Get a single file group by a group ID\n\n```ruby\nUploadcare::GroupApi.get_group(\"d476f4c9-44a9-4670-88a5-c3cf5d26a6c2~20\")\n#   =\u003e {\n#         \"cdn_url\"=\u003e\"https://ucarecdn.com/d476f4c9-44a9-4670-88a5-c3cf5d26a6c2~20/\",\n#          ...other group data...\n#         \"files\"=\u003e [{\n#            \"datetime_stored\"=\u003e\"2021-07-29T08:31:45.668354Z\",\n#            ...other file data...\n#         }]\n#      }\n```\n\n\n#### Store files of a group by a group ID\n\n```ruby\nUploadcare::GroupApi.store_group(\"d476f4c9-44a9-4670-88a5-c3cf5d26a6c2~20\")\n#   =\u003e \"200 OK\"\n```\n\n\n#### Create a new group by file's uuids.\n\nIt is possible to specify transformed URLs with UUIDs of files OR just UUIDs.\n\n```\n  NOTE: Be sure to add a trailing slash \"/\" to the URL in case of specifying transformed URLs.\n```\n\n```ruby\nUploadcare::GroupApi.create_group([\"e08dec9e-7e25-49c5-810e-4c360d86bbae/-/resize/300x500/\"])\n#   =\u003e {\n#         \"cdn_url\"=\u003e\"https://ucarecdn.com/d476f4c9-44a9-4670-88a5-c3cf5d26a6c2~1/\",\n#          ...other group data...\n#         \"files\"=\u003e [{\n#            \"datetime_stored\"=\u003e\"2021-07-29T08:31:45.668354Z\",\n#            ...other file data...\n#         }]\n#      }\n```\n\n\n#### Delete a file group by its ID\n\n```ruby\nUploadcare::GroupApi.delete_group(\"90c93e96-965b-4dd2-b323-39d9bd5f492c~1\")\n#   =\u003e \"200 OK\"\n```\n\n\n### Project API\n\nProjectApi interface provides just one method - to get a configuration of your Uploadcare project.\n\n```ruby\nUploadcare::ProjectApi.get_project\n#   =\u003e {\n#        \"collaborators\"=\u003e[],\n#        \"name\"=\u003e\"New project\",\n#        \"pub_key\"=\u003e\"your_public_key\",\n#        \"autostore_enabled\"=\u003etrue\n#      }\n```\n\n\n### Webhook API\n\nWebhookApi allows to manage Uploadcare webhooks.\n\n#### Get all webhooks\n\nThis method returns a non-paginated list of webhooks set in your project\n\n```ruby\nUploadcare::WebhookApi.get_webhooks\n#   =\u003e [{\n#        \"id\"=\u003e815677,\n#        \"created\"=\u003e\"2021-08-02T05:02:14.588794Z\",\n#        \"updated\"=\u003e\"2021-08-02T05:02:14.588814Z\",\n#        \"event\"=\u003e\"file.uploaded\",\n#        \"target_url\"=\u003e\"https://example.com\",\n#        \"project\"=\u003e123682,\n#        \"is_active\"=\u003etrue\n#      }]\n```\n\n\n#### Create a new webhook\n\nThis method requires an URL that is triggered by an event, for example, a file upload. A target URL MUST be unique for each project — event type combination.\n\nEach webhook payload can be signed with a secret (the `signing_secret` option) to ensure that the request comes from the expected sender.\nMore info about secure webhooks [here](https://uploadcare.com/docs/security/secure-webhooks/).\n\n```ruby\n# Valid options:\n# event: [\"file.uploaded\"]\n# is_active: [true|false]\nUploadcare::WebhookApi.create_webhook(\"https://example.com\", event: \"file.uploaded\", is_active: true, signing_secret: \"some-secret\")\n#   =\u003e {\n#        \"id\"=\u003e815671,\n#        \"created\"=\u003e\"2021-08-02T05:02:14.588794Z\",\n#        \"updated\"=\u003e\"2021-08-02T05:02:14.588814Z\",\n#        \"event\"=\u003e\"file.uploaded\",\n#        \"target_url\"=\u003e\"https://example.com\",\n#        \"project\"=\u003e123682,\n#        \"is_active\"=\u003etrue\n#      }\n```\n\n\n#### Update an existing webhook by ID\n\nUpdating a webhook is available if webhook ID is known. The ID is returned in a response on creating or listing webhooks. Setting a signing secret is supported when updating a webhook as well.\n\n```ruby\n# Valid options:\n# event: Presently, we only support the \"file.uploaded\" event\n# is_active: [true|false]\nUploadcare::WebhookApi.update_webhook(\"webhook_id\", target_url: \"https://example1.com\", event: \"file.uploaded\", is_active: false, signing_secret: \"some-secret\")\n#   =\u003e {\n#        \"id\"=\u003e815671,\n#        \"created\"=\u003e\"2021-08-02T05:02:14.588794Z\",\n#        \"updated\"=\u003e\"2021-08-02T05:02:14.588814Z\",\n#        \"event\"=\u003e\"file.uploaded\",\n#        \"target_url\"=\u003e\"https://example1.com\",\n#        \"project\"=\u003e123682,\n#        \"is_active\"=\u003efalse\n#      }\n```\n\n\n#### Delete an existing webhook by a target_url\n\n```ruby\nUploadcare::WebhookApi.delete_webhook(\"https://example1.com\")\n#   =\u003e Success(nil)\n```\n\n### Conversion API\n\nConversionApi provides methods to manage video and documents conversion.\n\n#### Convert a document\n\nThis method requires an UUID of a previously uploaded to Uploadcare file and target format.\nIf using an image format, you can also specify a page number that must be converted for a document containing pages.\nMore info about document conversion can be found [here](https://uploadcare.com/docs/transformations/document-conversion/).\n\n```ruby\nUploadcare::ConversionApi.convert_document(\n  { uuid: \"466740dd-cfad-4de4-9218-1ddc0edf7aa6\", format: \"png\", page: 1 },\n  store: false\n)\n#   =\u003e Success({\n#        :result=\u003e[{\n#          :original_source=\u003e\"466740dd-cfad-4de4-9218-1ddc0edf7aa6/document/-/format/png/-/page/1/\",\n#          :token=\u003e21316034,\n#          :uuid=\u003e\"db6e52b8-cc03-4174-a07a-012be43b144e\"\n#        }],\n#        :problems=\u003e{}\n#     })\n```\n\n\n#### Get a document conversion job status\n\nThis method requires a token obtained in a response to the [convert_document](#convert-a-document) method.\n\n```ruby\nUploadcare::ConversionApi.get_document_conversion_status(21316034)\n#   =\u003e Success({\n#        :result=\u003e{\n#          :uuid=\u003e\"db6e52b8-cc03-4174-a07a-012be43b144e\"\n#        },\n#        :error=\u003enil,\n#        :status=\u003e\"finished\"\n#     })\n```\n\n\n#### Convert a video\n\nSuch as the document conversion method, this method requires an UUID of a previously uploaded to Uploadcare file.\nAlso you have several options to control the way a video will be converted. All of them are optional.\nDescription of valid options and other info about video conversion can be found [here](https://uploadcare.com/docs/transformations/video-encoding/).\n\n```ruby\nUploadcare::ConversionApi.convert_video(\n  {\n    uuid: \"466740dd-cfad-4de4-9218-1ddc0edf7aa6\",\n    format: \"ogg\",\n    quality: \"best\",\n    cut: { start_time: \"0:0:0.0\", length: \"0:0:1.0\" },\n    thumbs: { N: 2, number: 1 }\n  },\n  store: false\n)\n#   =\u003e Success({\n#        :result=\u003e[{\n#          :original_source=\u003e\"80b807be-faad-4f01-bbbe-0bbde172b9de/video/-/size/600x400/change_ratio/-/quality/best/-/format/ogg/-/cut/0:0:0.0/0:0:1.0/-/thumbs~2/1/\",\n#          :token=\u003e916090555,\n#          :uuid=\u003e\"df597ef4-59e7-47ef-af5d-365d8409934c~2\",\n#          :thumbnails_group_uuid=\u003e\"df597ef4-59e7-47ef-af5d-365d8409934c~2\"\n#        }],\n#        :problems=\u003e{}\n#     })\n```\n\n\n#### Get a video conversion job status\n\nThis method requires a token obtained in a response to the [convert_video](#convert-a-video) method.\n\n```ruby\nUploadcare::ConversionApi.get_video_conversion_status(916090555)\n#   =\u003e Success({\n#        :result=\u003e{\n#          :uuid=\u003e\"f0a3e66e-cd22-4397-ba0a-8a8becc925f9\",\n#          :thumbnails_group_uuid=\u003e\"df597ef4-59e7-47ef-af5d-365d8409934c~2\"\n#        },\n#        :error=\u003enil,\n#        :status=\u003e\"finished\"\n#     })\n```\n\n\n### File Metadata Api\n\nFile metadata is additional, arbitrary data, associated with uploaded file.\nAs an example, you could store unique file identifier from your system.\nMetadata is key-value data.\n\n#### Get file's metadata keys and values\n\n```ruby\nUploadcare::FileMetadataApi.file_metadata('f757ea10-8b1a-4361-9a7c-56bfa5d45176')\n#   =\u003e {:\"sample-key\"=\u003e\"sample-value\"}\n```\n\n#### Get the value of a single metadata key\n\n```ruby\nUploadcare::FileMetadataApi.file_metadata_value('f757ea10-8b1a-4361-9a7c-56bfa5d45176', 'sample-key')\n#   =\u003e \"sample-value\"\n```\n\n#### Update the value of a single metadata key\n\nIf the key does not exist, it will be created.\n\n```ruby\nUploadcare::FileMetadataApi.update_file_metadata('f757ea10-8b1a-4361-9a7c-56bfa5d45176', 'sample-key', 'new-value')\n#   =\u003e \"new-value\"\n```\n\n#### Delete a file's metadata key\n\n```ruby\nUploadcare::FileMetadataApi.delete_file_metadata('f757ea10-8b1a-4361-9a7c-56bfa5d45176', 'sample-key')\n#   =\u003e \"200 OK\"\n```\n\n\n### Add-Ons Api\n\nAn Add-On is an application implemented by Uploadcare that accepts uploaded files as an input and can produce other files and/or appdata as an output.\n\n#### Execute AWS Rekognition Add-On for a given target to detect labels in an image\n\n```\n  Note: Detected labels are stored in the file's appdata.\n```\n\n```ruby\nUploadcare::AddonsApi.rekognition_detect_labels('f757ea10-8b1a-4361-9a7c-56bfa5d45176')\n#   =\u003e {\"request_id\"=\u003e\"dfeaf81c-5c0d-49d5-8ed4-ac09bac7998e\"}\n```\n\n#### Check the status of an Add-On execution request that had been started using the Execute Add-On operation\n\n```ruby\nUploadcare::AddonsApi.rekognition_detect_labels_status('dfeaf81c-5c0d-49d5-8ed4-ac09bac7998e')\n#   =\u003e {\"status\"=\u003e\"done\"}\n```\n\n#### Execute AWS Rekognition Moderation Add-On for a given target to detect moderation labels in an image.\n```\n  Note: Detected labels are stored in the file's appdata.\n```\n\n```ruby\nUploadcare::AddonsApi.rekognition_detect_moderation_labels('f757ea10-8b1a-4361-9a7c-56bfa5d45176')\n#   =\u003e {\"request_id\"=\u003e\"dfeaf81c-5c0d-49d5-8ed4-ac09bac7998e\"}\n```\n\n# Check the status of an AWS Rekognition Moderation Add-On execution request that had been started using the Execute Add-On operation.\n\n```ruby\nUploadcare::AddonsApi.rekognition_detect_moderation_labels_status('dfeaf81c-5c0d-49d5-8ed4-ac09bac7998e')\n#   =\u003e {\"status\"=\u003e\"done\"}\n```\n\n\n\n#### Execute ClamAV virus checking Add-On for a given target\n\n```ruby\nUploadcare::AddonsApi.virus_scan('dfeaf81c-5c0d-49d5-8ed4-ac09bac7998e')\n#   =\u003e {\"request_id\"=\u003e\"1b0126de-ace6-455b-82e2-25f4aa33fc6f\"}\n```\n\n#### Check the status of an Add-On execution request that had been started using the Execute Add-On operation\n\n```ruby\nUploadcare::AddonsApi.virus_scan_status('1b0126de-ace6-455b-82e2-25f4aa33fc6f')\n#   =\u003e {\"status\"=\u003e\"done\"}\n```\n\n#### Execute remove.bg background image removal Add-On for a given target\n\n```ruby\nUploadcare::AddonsApi.remove_bg('f757ea10-8b1a-4361-9a7c-56bfa5d45176')\n#   =\u003e {\"request_id\"=\u003e\"6d26a7d5-0955-4aeb-a9b1-c9776c83aa4c\"}\n```\n\n#### Check the status of an Add-On execution request that had been started using the Execute Add-On operation\n\n```ruby\nUploadcare::AddonsApi.remove_bg_status('6d26a7d5-0955-4aeb-a9b1-c9776c83aa4c')\n#   =\u003e {\"status\"=\u003e\"done\", \"result\"=\u003e{\"file_id\"=\u003e\"8f0a2a28-3ed7-481e-b415-ee3cce982aaa\"}}\n```\n\n\n## Useful links\n* [Uploadcare documentation](https://uploadcare.com/docs/?utm_source=github\u0026utm_medium=referral\u0026utm_campaign=uploadcare-rails)\n* [Upload API reference](https://uploadcare.com/api-refs/upload-api/?utm_source=github\u0026utm_medium=referral\u0026utm_campaign=uploadcare-rails)\n* [REST API reference](https://uploadcare.com/api-refs/rest-api/?utm_source=github\u0026utm_medium=referral\u0026utm_campaign=uploadcare-rails)\n* [Changelog](./CHANGELOG.md)\n* [Contributing guide](https://github.com/uploadcare/.github/blob/master/CONTRIBUTING.md)\n* [Security policy](https://github.com/uploadcare/uploadcare-rails/security/policy)\n* [Support](https://github.com/uploadcare/.github/blob/master/SUPPORT.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuploadcare%2Fuploadcare-rails","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuploadcare%2Fuploadcare-rails","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuploadcare%2Fuploadcare-rails/lists"}