uploadcare-rails 3.3.2 → 3.3.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 225f89d33b93878d70c384b7c91f5397851cffa60259fb9cb4cb379f7ee97d16
4
- data.tar.gz: c5c5069a828b241971809cfb3c84cf305bbff7e8fc8847afd9afb79f6c7973b8
3
+ metadata.gz: 337ca39681c735dffe71dcc95c0a5a969290cb702f845cbb95691bd820f1ffec
4
+ data.tar.gz: b2666c556bd0fa86a13c8892d47f7ca32a19e42ac3faccd9686d07035f5f2174
5
5
  SHA512:
6
- metadata.gz: ee85739c5ed15ae4f447e4ff75da6f3aaa07be87a378d513cb3b34231d2f48b03b61f0b46a64d06d4efc97e65b54303ce1e147246cc47571035eff23a67a046d
7
- data.tar.gz: c284143183caedd74fec7fcc693d8223707b94933df3ac9c581033de785cbaa533cdff8dba36ccfe9418a9d2e83a88b252298eb4c1b0c0914ca8f45d37dbb44e
6
+ metadata.gz: 1ea70005621475a6892a155e0441f5ddddb7cfcc75b3b9b9968a27f0870adef177c3de763a6d885060a571a9f18881cb9b03eca6a5624ac7db452bcfd1a829f4
7
+ data.tar.gz: 33f3b7cbb9bf9091fb7a0a0803f5eecd29593d3e618b541ec82051cb0f369c4011a9790e166fde573794ed6c5a8a3ea6cfcea96b7d77608f2e9beb8bee9ee763
data/CHANGELOG.md ADDED
@@ -0,0 +1,170 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based now on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
+ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
+
7
+ ## 3.3.2.1 — 2023-03-26
8
+
9
+ ### Changed
10
+
11
+ * Updated links in the gemspec
12
+
13
+ ## 3.3.2 — 2023-03-26
14
+
15
+ ### Changed
16
+
17
+ * Fixed an issue with the configuration
18
+ * Updated the gem documentation
19
+
20
+ ## 3.3.1 — 2023-03-20
21
+
22
+ * Update gem description
23
+ * Respect data-multiple in helper options (https://github.com/uploadcare/uploadcare-rails/issues/119)
24
+
25
+ ## 3.3.0 — 2023-03-16
26
+
27
+ Guarantee support of maintainable versions of Ruby and Rails
28
+
29
+ ### Breaking Сhanges
30
+
31
+ Drop support of unmaintainable Ruby 2.4, 2.5, 2.6 and Rails before 6.0
32
+
33
+ ### Added
34
+
35
+ Add support of Ruby 3.1 and 3.2 and Rails 7.0
36
+
37
+ ## 3.0.0 — 2022-12-29
38
+
39
+ This version supports latest Uploadcare REST API — [v0.7](https://uploadcare.com/api-refs/rest-api/v0.7.0/), which introduces new file management features:
40
+ * [File metadata](https://uploadcare.com/docs/file-metadata/)
41
+ * New [add-ons API](https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/Add-Ons):
42
+ * [Background removal](https://uploadcare.com/docs/remove-bg/)
43
+ * [Virus checking](https://uploadcare.com/docs/security/malware-protection/)
44
+ * [Object recognition](https://uploadcare.com/docs/intelligence/object-recognition/)
45
+
46
+ ### Breaking Сhanges
47
+
48
+ - For `Uploadcare::FileApi#get_file`
49
+ - File information doesn't return `image_info` and `video_info` fields anymore
50
+ - Removed `rekognition_info` in favor of `appdata`
51
+ - Parameter `add_fields` was renamed to `include`
52
+ - For `Uploadcare::FileApi#get_files`
53
+ - Removed the option of sorting the file list by file size
54
+ - For `Uploadcare::GroupApi#store_group`
55
+ - Changed response format
56
+ - For `Uploadcare::FileApi`
57
+ - Removed method `copy_file` in favor of `local_copy_file` and `remote_copy_file` methods
58
+
59
+ ### Changed
60
+
61
+ - For `Uploadcare::FileApi#get_file`
62
+ - Field `content_info` that includes mime-type, image (dimensions, format, etc), video information (duration, format, bitrate, etc), audio information, etc
63
+ - Field `metadata` that includes arbitrary metadata associated with a file
64
+ - Field `appdata` that includes dictionary of application names and data associated with these applications
65
+
66
+ ### Added
67
+
68
+ - Add Uploadcare API interface:
69
+ - `Uploadcare::FileMetadataApi`
70
+ - `Uploadcare::AddonsApi`
71
+ - Added an option to delete a Group
72
+ - For `Uploadcare::FileApi` add `local_copy_file` and `remote_copy_file` methods
73
+
74
+ ## 2.1.1 2022-05-13
75
+ ### Fix
76
+
77
+ Fixed Rails 4 tests by enforcing https.
78
+
79
+ ## 2.1.0 2021-11-16
80
+ ### Added
81
+
82
+ - Option `signing_secret` in the `Uploadcare::WebhookApi`.
83
+
84
+ ## 2.0.0 - 2021-10-11
85
+ ### :heavy_exclamation_mark: *Note: the gem uploadcare-rails 2.x is not backward compatible with 1.x.*
86
+
87
+ ### Added
88
+
89
+ - Add Uploadcare API interface:
90
+ - Uploadcare::FileApi
91
+ - Uploadcare::UploadApi
92
+ - Uploadcare::GroupApi
93
+ - Uploadcare::ConversionApi
94
+ - Uploadcare::ProjectApi
95
+ - Uploadcare::WebhookApi
96
+ - Add uploadcare_widget_tag helper for views
97
+ - Add methods File#store, File#delete, File#load
98
+ - Add methods Group#transform_file_urls, Group#store, Group#load
99
+
100
+ ### Changed
101
+
102
+ - Change File Uploader widget view helpers
103
+ - Rename has_uploadcare_file -> mount_uploadcare_file
104
+ - Rename has_uploadcare_group -> mount_uploadcare_file_group
105
+ - Change generated config path from config/uploadcare.yml to config/initializers/uploadcare.rb and add more options
106
+ - Rename the class `Uploadcare::Rails::Settings` to `Uploadcare::Rails::Configuration`
107
+ - Rename the class `Uploadcare::Rails::Operations` to `Uploadcare::Rails::Transformations::ImageTransformations`.
108
+ Configuration object is available as `Uploadcare::Rails.configuration` now
109
+ - Change methods File#url -> File#transform_url
110
+ - Change methods Group#urls -> Group#file_urls
111
+ - Change methods Group#load_data -> Group#load
112
+
113
+ ### Removed
114
+
115
+ - Remove uploadcare_uploader_tag helper
116
+ - Remove uploadcare_multiple_uploader_field helper
117
+ - Remove uploadcare_single_uploader_field helper
118
+ - Remove uploadcare_uploader_options (now options are included in uploadcare_widget_tag)
119
+ - Remove FormBuilder support
120
+ - Remove Formtastic support
121
+ - Remove SimpleForm support
122
+ - Remove caching files and groups on delete
123
+ - Remove callback ```ruby after_save after_save "store_#{ attribute }".to_sym```. Now managed by the `do_not_store` option in `config/initializers/uploadcare.rb`
124
+ - Remove methods File#prepared_operations, File#to_builder, File#to_json, File#as_json, File#marshal_dump, File#image
125
+ - Remove methods Group#cache_data, Group#to_json, Group#as_json, Group#map_files, Group#load_data!, Group#marshal_dump
126
+
127
+ ## 1.2.1 - 2018-10-01
128
+ ### Fixed
129
+ - Allow to use multiple files or groups
130
+
131
+ ## 1.2.0 - 2018-06-03
132
+
133
+ ## 1.2.0-alpha3 - 2018-05-29
134
+ ### Fixed
135
+
136
+ - Require `uploadcare/rails/version` in `lib/uploadcare-rails.rb`
137
+
138
+ ## 1.2.0-alpha2 - 2018-05-28 - YANKED
139
+ ### Changed
140
+ - Gem now reports us your `uploadcare-rails` and `rails` versions using the User-Agent header (overridable via config)
141
+ - `uploadcare-ruby` gem version bumped to 1.2.x
142
+
143
+
144
+ ## 1.2.0-alpha - 2018-04-18
145
+ ### Changed
146
+ - Allow gem in rails 5.2
147
+ - Update default widget version to 3.x
148
+
149
+ ### Removed
150
+ - Tests against Ruby 2.0 and 2.1 that [had reached their EOL](https://www.ruby-lang.org/en/downloads/branches/)
151
+
152
+
153
+ ## 1.1.1 - 2017-11-07
154
+ ### Fixed
155
+ - Uploadcare config generator
156
+ - Issues preventing the gem to be used with rails 5.1
157
+
158
+
159
+ ## 1.1.0 - 2016-07-12
160
+ ### Added
161
+ - Removed widget from the asset pipeline. It is expected to use helper or to append to the asset pipeline manually.
162
+ - Operations for image_tag helpers.
163
+
164
+ ### Fixed
165
+ - Bug with creating object with empty file or file_group.
166
+ - Workaround to remove unnecessary API-calls for groups of images.
167
+
168
+ ### Development
169
+ - Tests have been refactored, VCR appended to development environment.
170
+ - Tests performance improvements.
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in uploadcare-rails.gemspec
6
+ gemspec
7
+
8
+ gem 'http-parser', '~> 1.2', '>= 1.2.3'
9
+ gem 'rake', '~> 13.0.6'
10
+ gem 'rspec', '~> 3.10'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 dmitrij
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,969 @@
1
+ # Uploadcare Rails
2
+
3
+ ![license](https://img.shields.io/badge/license-MIT-brightgreen.svg)
4
+ [![Build Status][actions-img]][actions-badge]
5
+
6
+ [actions-badge]: https://github.com/uploadcare/uploadcare-rails/actions/workflows/test.yml
7
+ [actions-img]: https://github.com/uploadcare/uploadcare-rails/actions/workflows/test.yml/badge.svg
8
+
9
+ A Ruby on Rails plugin for [Uploadcare](https://uploadcare.com) service.
10
+ Based on [uploadcare-ruby](https://github.com/uploadcare/uploadcare-ruby) gem (general purpose wrapper for Uploadcare API)
11
+
12
+ ### :heavy_exclamation_mark: *Note: the gem uploadcare-rails 2.x is not backward compatible with 1.x.*
13
+
14
+ * [Requirements](#requirements)
15
+ * [Installation](#installation)
16
+ * [Using Gemfile](#using-gemfile)
17
+ * [Using command line](#using-command-line)
18
+ * [Usage](#usage)
19
+ * [Configuration](#configuration)
20
+ * [Uploadcare File Uploader](#uploadcare-file-uploader)
21
+ * [Widget](#widget)
22
+ * [Using CDN](#using-cdn)
23
+ * [Using NPM](#using-npm)
24
+ * [Input](#input)
25
+ * [Using the File Uploader with Rails models](#using-the-file-uploader-with-rails-models)
26
+ * [Form data](#form-data)
27
+ * [File and Group wrappers](#file-and-group-wrappers)
28
+ * [Image Transformation](#image-transformation)
29
+ * [Uploadcare API interfaces](#uploadcare-api-interfaces)
30
+ * [Upload Api](#upload-api)
31
+ * [File Api](#file-api)
32
+ * [Group Api](#group-api)
33
+ * [Project Api](#project-api)
34
+ * [Webhook Api](#webhook-api)
35
+ * [Conversion Api](#conversion-api)
36
+ * [File Metadata Api](#file-metadata-api)
37
+ * [Add-Ons Api](#add-ons-api)
38
+ * [Useful links](#useful-links)
39
+
40
+ ## Requirements
41
+ * ruby 2.7+
42
+ * Ruby on Rails 6.0+
43
+
44
+ ## Installation
45
+
46
+ ### Using Gemfile
47
+
48
+ Add this line to your application's Gemfile:
49
+
50
+ ```ruby
51
+ gem "uploadcare-rails"
52
+ ```
53
+
54
+ And then execute:
55
+
56
+ ```console
57
+ $ bundle install
58
+ ```
59
+
60
+ If you use `api_struct` gem in your project, replace it with `uploadcare-api_struct`:
61
+ ```ruby
62
+ gem 'uploadcare-api_struct'
63
+ ```
64
+ and run `bundle install`
65
+
66
+ ### Using command line
67
+
68
+ ```console
69
+ $ gem install uploadcare-rails
70
+ ```
71
+
72
+ ## Usage
73
+
74
+ ### Configuration
75
+
76
+ To start using Uploadcare API you just need to set your [API keys](https://app.uploadcare.com/projects/-/api-keys/) (public key and secret key).
77
+ These keys can be set as ENV variables using the `export` directive:
78
+
79
+ ```console
80
+ $ export UPLOADCARE_PUBLIC_KEY=your_public_key
81
+ $ export UPLOADCARE_SECRET_KEY=your_private_key
82
+ ```
83
+ Or you can use popular gems like `dotenv-rails` for setting ENV variables.
84
+ You must set the gem before `uploadcare-rails` like this :
85
+ ```ruby
86
+ gem "dotenv-rails", require: "dotenv/rails-now", groups: [:development, :test]
87
+ gem "uploadcare-rails"
88
+ ```
89
+ :warning: `require: "dotenv/rails-now"` is very important!
90
+
91
+ Run the config generator command to generate a configuration file:
92
+
93
+ ```console
94
+ $ rails g uploadcare_config
95
+ ```
96
+
97
+ The generator will create a new file in `config/initializers/uploadcare.rb`.
98
+
99
+ The public key must be specified in `config/initializers/uploadcare.rb` to use Uploadcare file upload.
100
+ This step is done automatically in the initializer if you set the ENV variable `UPLOADCARE_PUBLIC_KEY` earlier.
101
+
102
+ ```ruby
103
+ ...
104
+ Uploadcare::Rails.configure do |config|
105
+ # Sets your Uploadcare public key.
106
+ config.public_key = ENV.fetch("UPLOADCARE_PUBLIC_KEY", "your_public_key")
107
+ ...
108
+ end
109
+ ```
110
+
111
+ There are also some options set by default:
112
+
113
+ ```ruby
114
+ ...
115
+ # Deletes files from Uploadcare servers after object destroy.
116
+ config.delete_files_after_destroy = true
117
+
118
+ # Sets caching for Uploadcare files
119
+ config.cache_files = true
120
+
121
+ # Available locales currently are:
122
+ # 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
123
+ config.locale = "en"
124
+
125
+ # If true, inputs on your page are initialized automatically, see the article for details -
126
+ # https://uploadcare.com/docs/file-uploader-api/widget-initialization/
127
+ config.live = true
128
+
129
+ # If true, input initialization is invoked manually.
130
+ # See https://uploadcare.com/docs/file-uploader-api/widget-initialization/).
131
+ config.manual_start = false
132
+ ```
133
+
134
+ Then you can configure all global variables such as files storing/caching, deleting files, etc.
135
+ Full list of available options is listed in the file itself. Just uncomment an option and set the value.
136
+
137
+
138
+ ### Uploadcare File Uploader
139
+
140
+ ### Widget
141
+
142
+ #### Using CDN
143
+
144
+ The fastest way to start using file uploading is to add the Uploadcare widget to the html-page.
145
+ There is a view helper that can do it with two strings of code:
146
+
147
+ Add this string to your <head> html-tag
148
+
149
+ ```erb
150
+ <!DOCTYPE html>
151
+ <html>
152
+ <head>
153
+ <title>RailsApp</title>
154
+ <%= uploadcare_widget_tag %>
155
+ <!--
156
+ results in:
157
+ <script src="https://ucarecdn.com/libs/widget/3.x/uploadcare.full.min.js"></script>
158
+ <script>
159
+ //<![CDATA[
160
+ UPLOADCARE_PUBLIC_KEY = "your_public_key";
161
+ UPLOADCARE_LOCALE = "en";
162
+ UPLOADCARE_LIVE = true;
163
+ UPLOADCARE_MANUAL_START = false;
164
+ //]]>
165
+ </script>
166
+ -->
167
+ </head>
168
+ ...
169
+ ```
170
+ This helper uses a CDN-url for the widget bundle and supports three options:
171
+
172
+ - **version** — version of the Uploadcare widget. Default is "3.x".
173
+ - **bundle** — bundle name. Available names are "full", "default", "api", "ie8" and "lang.en".
174
+ Default bundle is "full" — a full bundle with built-in jQuery.
175
+ More info about bundles [here](https://uploadcare.com/docs/uploads/file-uploader/#bundles).
176
+ - **min** — bool value detecting if the bundle must be minified.
177
+
178
+ The <head> tag then also includes the <script> with widget global settings set in `config/initializers/uploadcare.rb`. You can override them later in an individual widget.
179
+
180
+
181
+ #### Using asset pipeline.
182
+
183
+ Download 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.
184
+
185
+ #### Using NPM
186
+
187
+ Installing via NPM instructions can be found [here](https://uploadcare.com/docs/uploads/file-uploader/#npm).
188
+
189
+ ### Input
190
+
191
+ When the widget is on a html-page, you want to add an input to your view that will be used by the File Uploader:
192
+
193
+ ```erb
194
+ ...
195
+ <%= uploadcare_uploader_field :object, :attribute %>
196
+ <!--
197
+ results in:
198
+ <input role="uploadcare-uploader" type="hidden" name="object[attribute]" id="object_attribute">
199
+ -->
200
+ ...
201
+ ```
202
+
203
+ - **object** — object name;
204
+ - **attribute** — object attribute name.
205
+
206
+ ### Using the File Uploader with Rails models
207
+
208
+ View helpers are good to be used for Rails models.
209
+ First, you need to mount uploadcare file or group to the model attribute.
210
+ For example you have a database table like this and model `Post`:
211
+ ```
212
+ # DB table "posts"
213
+ ---------------------
214
+ title | String
215
+ ---------------------
216
+ picture | String
217
+ ---------------------
218
+ attachments | String
219
+ ---------------------
220
+ ```
221
+
222
+ ### Form data
223
+
224
+ #### Uploadcare File
225
+
226
+ ```ruby
227
+ # app/models/post.rb
228
+ class Post < ApplicationRecord
229
+ mount_uploadcare_file :picture
230
+ end
231
+ ```
232
+
233
+ ```erb
234
+ <!-- app/views/posts/new.html.erb -->
235
+ <h1> NEW POST </h1>
236
+
237
+ <%= form_tag("/posts", method: :post) do %>
238
+ <%= uploadcare_uploader_field :post, :picture %>
239
+ <!--
240
+ results in:
241
+ <input role="uploadcare-uploader" multiple="false" type="hidden" name="post[picture]" id="post_picture">
242
+ -->
243
+ <div>
244
+ <%= submit_tag "Save" %>
245
+ </div>
246
+ <% end %>
247
+ ```
248
+
249
+ #### Uploadcare File Group
250
+
251
+ ```ruby
252
+ # app/models/post.rb
253
+ class Post < ApplicationRecord
254
+ mount_uploadcare_file_group :attachments
255
+ end
256
+ ```
257
+
258
+ ```erb
259
+ <!-- app/views/posts/new.html.erb -->
260
+ <h1> NEW POST </h1>
261
+
262
+ <%= form_tag("/posts", method: :post) do %>
263
+ <%= uploadcare_uploader_field :post, :attachments %>
264
+ <!--
265
+ results in:
266
+ <input role="uploadcare-uploader" multiple="true" type="hidden" name="post[attachments]" id="post_attachments">
267
+ -->
268
+ <div>
269
+ <%= submit_tag "Save" %>
270
+ </div>
271
+ <% end %>
272
+ ```
273
+
274
+ The input will have a `value` property set to CDN-urls when you will select files to upload in the widget.
275
+
276
+ ```erb
277
+ <input role="uploadcare-uploader" type="hidden" name="post[picture]" id="post_picture" value="https://ucarecdn.com/8355c2c5-f108-4d74-963d-703d48020f83/">
278
+ ```
279
+
280
+ So, you get CDN-urls as a value of the attribute in the controller on form submit.
281
+ The value will be available in the controller by `params[:post][:picture]`.
282
+
283
+ The helper is detecting the value of the `multiple` property based on the mount type in your model.
284
+
285
+ ### File and Group wrappers
286
+
287
+ When you mount either Uploadcare File or Group to an attribute, this attribute is getting wrapped with
288
+ a Uploadcare object. This feature adds some usefull methods to the attribute.
289
+
290
+ #### Uploadcare File
291
+
292
+ Say, you have such model in your Rails app:
293
+
294
+ ```ruby
295
+ # app/models/post.rb
296
+ class Post < ApplicationRecord
297
+ mount_uploadcare_file :picture
298
+ end
299
+ ```
300
+
301
+ And then you create a new Post object specifying a CDN-url for your prevously uploaded Uploadcare file:
302
+
303
+ ```console
304
+ $ post = Post.create(picture: "https://ucarecdn.com/2d33999d-c74a-4ff9-99ea-abc23496b052/")
305
+ ```
306
+
307
+ Now the `post.picture` is an Uploadcare::Rails::File. Following methods are supported:
308
+
309
+ ```console
310
+ # Store the file on an Uploadcare server permanently:
311
+ $ post.picture.store
312
+ # => {
313
+ # "cdn_url"=>"https://ucarecdn.com/2d33999d-c74a-4ff9-99ea-abc23496b052/",
314
+ # ...other group data...
315
+ # }
316
+ #
317
+ # Delete the file from an Uploadcare server permanently:
318
+ $ post.picture.delete
319
+ # => {
320
+ # "datetime_removed"=>"2021-07-30T09:19:30.797174Z",
321
+ # ...other group data...
322
+ # }
323
+ #
324
+ # Get CDN-url of an object attribute:
325
+ $ post.picture.to_s
326
+ # => "https://ucarecdn.com/2d33999d-c74a-4ff9-99ea-abc23496b052/"
327
+ #
328
+ # Load object (send a GET request to the server to get all the file's data)
329
+ # This data will be cached if the cache_files option is set to true
330
+ # Default data (without asking an Uploadcare server) for each file contains cdn_url and uuid only:
331
+ $ post.picture.load
332
+ # => {
333
+ # "cdn_url"=>"https://ucarecdn.com/2d33999d-c74a-4ff9-99ea-abc23496b052/",
334
+ # ...other file data...
335
+ # }
336
+ #
337
+ # Check if an attribute loaded from the server.
338
+ # Will return false unless the :load or the :store methods are called:
339
+ $ post.picture.loaded?
340
+ # => true
341
+ #
342
+ # More about image transformations below.
343
+ # Transform a CDN-url to get a new transformed image's source. Works for images only:
344
+ $ post.picture.transform_url(quality: "better")
345
+ # => "https://ucarecdn.com/2d33999d-c74a-4ff9-99ea-abc23496b052/-/quality/better/"
346
+ ```
347
+
348
+ #### Uploadcare File Group
349
+
350
+ Groups work similar to the File but have some differences though.
351
+
352
+ ```ruby
353
+ # app/models/post.rb
354
+ class Post < ApplicationRecord
355
+ mount_uploadcare_file_group :attachments
356
+ end
357
+ ```
358
+
359
+ Creating a new `post` with the Group mounted:
360
+
361
+ ```console
362
+ $ post = Post.create(attachments: "https://ucarecdn.com/dbc4e868-b7a6-43ff-a35f-2ebef935dc1b~1/")
363
+ ```
364
+
365
+ Now the `post.attachments` is an Uploadcare::Rails::Group. Following methods are supported:
366
+
367
+ ```console
368
+ # Store the file group on an Uploadcare server permanently:
369
+ $ post.attachments.store
370
+ # => {
371
+ # "cdn_url"=>"https://ucarecdn.com/dbc4e868-b7a6-43ff-a35f-2ebef935dc1b~1/",
372
+ # ...other group data...
373
+ # "files"=> [{
374
+ # "datetime_stored"=>"2021-07-29T08:31:45.668354Z",
375
+ # ...other file data...
376
+ # }]
377
+ # }
378
+ #
379
+ # Delete the file group from an Uploadcare server permanently:
380
+ $ post.attachments.delete
381
+ # => {
382
+ # "datetime_removed"=>"2021-07-30T09:19:30.797174Z",
383
+ # ...other group data...
384
+ # }
385
+ #
386
+ # Get CDN-url of an object attribute:
387
+ $ post.attachments.to_s
388
+ # => "https://ucarecdn.com/dbc4e868-b7a6-43ff-a35f-2ebef935dc1b~1/"
389
+ #
390
+ # Load object — works the same way as for the File:
391
+ $ post.attachments.load
392
+ # => {
393
+ # "cdn_url"=>"https://ucarecdn.com/dbc4e868-b7a6-43ff-a35f-2ebef935dc1b~1/",
394
+ # ...other group data...
395
+ # "files"=> [{
396
+ # "datetime_stored"=>"2021-07-29T08:31:45.668354Z",
397
+ # ...other file data...
398
+ # }]
399
+ # }
400
+ #
401
+ # Check if an attribute loaded from the server:
402
+ $ post.attachments.loaded?
403
+ # => true
404
+ #
405
+ # As we don't want to show (on the html-page) a file group itself,
406
+ # we can get CDN-urls for file that the group contains. No loading group or files needed.
407
+ # This works for images only:
408
+ $ post.attachments.transform_file_urls(quality: "better")
409
+ # => ["https://ucarecdn.com/dbc4e868-b7a6-43ff-a35f-2ebef935dc1b~1/nth/0/-/quality/better/"]
410
+ #
411
+ # If you want to get non-transformed file urls, use:
412
+ $ post.attachments.file_urls
413
+ # => ["https://ucarecdn.com/dbc4e868-b7a6-43ff-a35f-2ebef935dc1b~1/nth/0/"]
414
+ ```
415
+
416
+
417
+ ### Image Transformation
418
+
419
+ Uploadcare provides a way to transform images stored on Uploadcare services specifying a list of operations.
420
+ If an operation has just one option, you can specify it like key-value:
421
+
422
+ ```console
423
+ $ post.picture.transform_url(quality: "better")
424
+ # => "https://ucarecdn.com/ebbb9929-eb92-4f52-a212-eecfdb19d27d/-/quality/better/"
425
+ ```
426
+
427
+ and if an operation supports several options — just set them as a Hash:
428
+
429
+ ```console
430
+ $ post.picture.transform_url(crop: { dimensions: "300x500", coords: "50, 50", alignment: "center" })
431
+ # => "https://ucarecdn.com/ebbb9929-eb92-4f52-a212-eecfdb19d27d/-/crop/300x500/50,50/center/"
432
+ ```
433
+
434
+ Full list of operations and valid values can be found [here](https://uploadcare.com/docs/transformations/image/).
435
+
436
+ ### Uploadcare API interfaces
437
+
438
+ Uploadcare 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.
439
+
440
+ ### Upload API
441
+
442
+ [Upload Api](https://uploadcare.com/api-refs/upload-api/) provides methods to upload files in many ways.
443
+
444
+ #### Upload a single file
445
+
446
+ ```console
447
+ # Load a file
448
+ $ file = File.open("kitten.png")
449
+ # => #<File:kitten.png>
450
+ # Upload file to Uploadcare
451
+ $ uploadcare_file = Uploadcare::UploadApi.upload_file(file)
452
+ # => {
453
+ # "uuid"=>"2d33999d-c74a-4ff9-99ea-abc23496b053",
454
+ # ...other file data...
455
+ # }
456
+ ```
457
+
458
+ This 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).
459
+
460
+ ```console
461
+ # Upload file from URL
462
+ $ url = "https://ucarecdn.com/80b807be-faad-4f01-bbbe-0bbde172b9de/1secVIDEO.mp4"
463
+ $ uploadcare_file = Uploadcare::UploadApi.upload_file(url)
464
+ # => [
465
+ # {
466
+ # "size"=>22108,
467
+ # "uuid"=>"b5ed5e1d-a939-4fe4-bfb2-31d3867bb6s6",
468
+ # "original_filename"=>"1 sec VIDEO.mp4",
469
+ # "is_image"=>false,
470
+ # "image_info"=>nil,
471
+ # "is_ready"=>true,
472
+ # "mime_type"=>"video/mp4"
473
+ # }
474
+ # ]
475
+ ```
476
+
477
+
478
+ #### Upload several files
479
+
480
+ ```console
481
+ # Load a file
482
+ $ file = File.open("kitten.png")
483
+ # => #<File:kitten.png>
484
+ # Upload several files to Uploadcare
485
+ $ uploadcare_file = Uploadcare::UploadApi.upload_files([file])
486
+ # => [
487
+ # {
488
+ # "uuid"=>"2dfc94e6-e74e-4014-9ff5-a71b8928f4fa",
489
+ # "original_filename"=>:"kitten.png"
490
+ # }
491
+ # ]
492
+ ```
493
+
494
+
495
+ ### File API
496
+
497
+ FileApi provides an interface to manage single files, stored on Uploadcare Servers.
498
+
499
+ #### Get files
500
+
501
+ ```console
502
+ # Valid options:
503
+ # removed: [true|false]
504
+ # stored: [true|false]
505
+ # limit: (1..1000)
506
+ # ordering: ["datetime_uploaded"|"-datetime_uploaded"]
507
+ # from: A starting point for filtering files. The value depends on your ordering parameter value.
508
+ $ Uploadcare::FileApi.get_files(ordering: "datetime_uploaded", limit: 10)
509
+ # => {
510
+ # "next"=>nil,
511
+ # "previous"=>nil,
512
+ # "total"=>2,
513
+ # "per_page"=>10,
514
+ # "results"=> [
515
+ # {
516
+ # "datetime_removed"=>nil,
517
+ # ... file data ...
518
+ # }
519
+ # ]
520
+ # }
521
+ ```
522
+
523
+
524
+ #### Get a file by UUID
525
+
526
+ ```console
527
+ $ Uploadcare::FileApi.get_file("7b2b35b4-125b-4c1e-9305-12e8da8916eb")
528
+ # => {
529
+ # "cdn_url"=>"https://ucarecdn.com/7b2b35b4-125b-4c1e-9305-12e8da8916eb/",
530
+ # ...other file data...
531
+ # }
532
+ ```
533
+
534
+
535
+ #### Copy a file to default storage. Source can be UID or full CDN link
536
+
537
+ ```console
538
+ # Valid options:
539
+ # stored: [true|false]
540
+ $ Uploadcare::FileApi.local_copy_file("2d33999d-c74a-4ff9-99ea-abc23496b052", store: false)
541
+ # => {
542
+ # "uuid"=>"f486132c-2fa5-454e-9e70-93c5e01a7e04",
543
+ # ...other file data...
544
+ # }
545
+ ```
546
+
547
+ #### Copy a file to custom storage. Source can be UID or full CDN link
548
+
549
+ ```console
550
+ # Valid options:
551
+ # make_public: [true|false]
552
+ $ Uploadcare::FileApi.remote_copy_file("2d33999d-c74a-4ff9-99ea-abc23496b052", "mytarget", make_public: false)
553
+ # => {
554
+ # "uuid"=>"f486132c-2fa5-454e-9e70-93c5e01a7e04",
555
+ # ...other file data...
556
+ # }
557
+ ```
558
+
559
+
560
+ #### Store a file by UUID
561
+
562
+ ```console
563
+ $ Uploadcare::FileApi.store_file("2d33999d-c74a-4ff9-99ea-abc23496b052")
564
+ # => {
565
+ # "uuid"=>"2d33999d-c74a-4ff9-99ea-abc23496b052",
566
+ # ...other file data...
567
+ # }
568
+ ```
569
+
570
+
571
+ #### Store several files by UUIDs
572
+
573
+ ```console
574
+ $ Uploadcare::FileApi.store_files(["f486132c-2fa5-454e-9e70-93c5e01a7e04"])
575
+ # => {
576
+ # "result" => [
577
+ # {
578
+ # "uuid"=>"f486132c-2fa5-454e-9e70-93c5e01a7e04",
579
+ # ...other file data...
580
+ # }
581
+ # ]
582
+ # }
583
+ ```
584
+
585
+
586
+ #### Delete a file by UUID
587
+
588
+ ```console
589
+ $ Uploadcare::FileApi.delete_file("2d33999d-c74a-4ff9-99ea-abc23496b052")
590
+ # => {
591
+ # "uuid"=>"2d33999d-c74a-4ff9-99ea-abc23496b052",
592
+ # ...other file data...
593
+ # }
594
+ ```
595
+
596
+
597
+ #### Delete several files by UUIDs
598
+
599
+ ```console
600
+ $ Uploadcare::FileApi.delete_files(["f486132c-2fa5-454e-9e70-93c5e01a7e04"])
601
+ # => {
602
+ # "result" => [
603
+ # {
604
+ # "uuid"=>"f486132c-2fa5-454e-9e70-93c5e01a7e04",
605
+ # ...other file data...
606
+ # }
607
+ # ]
608
+ # }
609
+ ```
610
+
611
+
612
+ ### Group API
613
+
614
+ GroupApi provides an interface to manage file groups stored on Uploadcare Servers.
615
+
616
+ #### Get file groups
617
+
618
+ ```console
619
+ # Valid options:
620
+ # limit: (1..1000)
621
+ # ordering: ["datetime_created"|"-datetime_created"]
622
+ # from: A starting point for filtering group lists. MUST be a datetime value with T used as a separator.
623
+ # example: "2015-01-02T10:00:00"
624
+ $ Uploadcare::GroupApi.get_groups(ordering: "datetime_uploaded", limit: 10)
625
+ # => {
626
+ # "next"=>"next"=>"https://api.uploadcare.com/groups/?ordering=datetime_uploaded&limit=10&from=2021-07-16T11%3A12%3A12.236280%2B00%3A00&offset=0",
627
+ # "previous"=>nil,
628
+ # "total"=>82,
629
+ # "per_page"=>10,
630
+ # "results"=> [
631
+ # {
632
+ # "id"=>"d476f4c9-44a9-4670-88a5-c3cf5a26b6c2~20",
633
+ # "datetime_created"=>"2021-07-16T11:03:01.182239Z",
634
+ # "datetime_stored"=>nil,
635
+ # "files_count"=>20,
636
+ # "cdn_url"=>"https://ucarecdn.com/d476f4c9-44a9-4670-88a5-c3cf5d16b6c2~20/",
637
+ # "url"=>"https://api.uploadcare.com/groups/d476f4c9-44a9-4670-83a5-c3cf5d26b6c2~20/"
638
+ # },
639
+ # ... other groups data ...
640
+ # ]
641
+ # }
642
+ ```
643
+
644
+
645
+ #### Get a single file group by a group ID
646
+
647
+ ```console
648
+ $ Uploadcare::GroupApi.get_group("d476f4c9-44a9-4670-88a5-c3cf5d26a6c2~20")
649
+ # => {
650
+ # "cdn_url"=>"https://ucarecdn.com/d476f4c9-44a9-4670-88a5-c3cf5d26a6c2~20/",
651
+ # ...other group data...
652
+ # "files"=> [{
653
+ # "datetime_stored"=>"2021-07-29T08:31:45.668354Z",
654
+ # ...other file data...
655
+ # }]
656
+ # }
657
+ ```
658
+
659
+
660
+ #### Store files of a group by a group ID
661
+
662
+ ```console
663
+ $ Uploadcare::GroupApi.store_group("d476f4c9-44a9-4670-88a5-c3cf5d26a6c2~20")
664
+ # => "200 OK"
665
+ ```
666
+
667
+
668
+ #### Create a new group by file's uuids.
669
+
670
+ It is possible to specify transformed URLs with UUIDs of files OR just UUIDs.
671
+
672
+ ```
673
+ NOTE: Be sure to add a trailing slash "/" to the URL in case of specifying transformed URLs.
674
+ ```
675
+
676
+ ```console
677
+ $ Uploadcare::GroupApi.create_group(["e08dec9e-7e25-49c5-810e-4c360d86bbae/-/resize/300x500/"])
678
+ # => {
679
+ # "cdn_url"=>"https://ucarecdn.com/d476f4c9-44a9-4670-88a5-c3cf5d26a6c2~1/",
680
+ # ...other group data...
681
+ # "files"=> [{
682
+ # "datetime_stored"=>"2021-07-29T08:31:45.668354Z",
683
+ # ...other file data...
684
+ # }]
685
+ # }
686
+ ```
687
+
688
+
689
+ #### Delete a file group by its ID
690
+
691
+ ```console
692
+ $ Uploadcare::GroupApi.delete_group("90c93e96-965b-4dd2-b323-39d9bd5f492c~1")
693
+ # => "200 OK"
694
+ ```
695
+
696
+
697
+ ### Project API
698
+
699
+ ProjectApi interface provides just one method - to get a configuration of your Uploadcare project.
700
+
701
+ ```console
702
+ $ Uploadcare::ProjectApi.get_project
703
+ # => {
704
+ # "collaborators"=>[],
705
+ # "name"=>"New project",
706
+ # "pub_key"=>"your_public_key",
707
+ # "autostore_enabled"=>true
708
+ # }
709
+ ```
710
+
711
+
712
+ ### Webhook API
713
+
714
+ WebhookApi allows to manage Uploadcare webhooks.
715
+
716
+ #### Get all webhooks
717
+
718
+ This method returns a non-paginated list of webhooks set in your project
719
+
720
+ ```console
721
+ $ Uploadcare::WebhookApi.get_webhooks
722
+ # => [{
723
+ # "id"=>815677,
724
+ # "created"=>"2021-08-02T05:02:14.588794Z",
725
+ # "updated"=>"2021-08-02T05:02:14.588814Z",
726
+ # "event"=>"file.uploaded",
727
+ # "target_url"=>"https://example.com",
728
+ # "project"=>123682,
729
+ # "is_active"=>true
730
+ # }]
731
+ ```
732
+
733
+
734
+ #### Create a new webhook
735
+
736
+ This 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.
737
+
738
+ Each webhook payload can be signed with a secret (the `signing_secret` option) to ensure that the request comes from the expected sender.
739
+ More info about secure webhooks [here](https://uploadcare.com/docs/security/secure-webhooks/).
740
+
741
+ ```console
742
+ # Valid options:
743
+ # event: ["file.uploaded"]
744
+ # is_active: [true|false]
745
+ $ Uploadcare::WebhookApi.create_webhook("https://example.com", event: "file.uploaded", is_active: true, signing_secret: "some-secret")
746
+ # => {
747
+ # "id"=>815671,
748
+ # "created"=>"2021-08-02T05:02:14.588794Z",
749
+ # "updated"=>"2021-08-02T05:02:14.588814Z",
750
+ # "event"=>"file.uploaded",
751
+ # "target_url"=>"https://example.com",
752
+ # "project"=>123682,
753
+ # "is_active"=>true
754
+ # }
755
+ ```
756
+
757
+
758
+ #### Update an existing webhook by ID
759
+
760
+ Updating 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.
761
+
762
+ ```console
763
+ # Valid options:
764
+ # event: Presently, we only support the "file.uploaded" event
765
+ # is_active: [true|false]
766
+ $ Uploadcare::WebhookApi.update_webhook("webhook_id", target_url: "https://example1.com", event: "file.uploaded", is_active: false, signing_secret: "some-secret")
767
+ # => {
768
+ # "id"=>815671,
769
+ # "created"=>"2021-08-02T05:02:14.588794Z",
770
+ # "updated"=>"2021-08-02T05:02:14.588814Z",
771
+ # "event"=>"file.uploaded",
772
+ # "target_url"=>"https://example1.com",
773
+ # "project"=>123682,
774
+ # "is_active"=>false
775
+ # }
776
+ ```
777
+
778
+
779
+ #### Delete an existing webhook by a target_url
780
+
781
+ ```console
782
+ $ Uploadcare::WebhookApi.delete_webhook("https://example1.com")
783
+ # => Success(nil)
784
+ ```
785
+
786
+ ### Conversion API
787
+
788
+ ConversionApi provides methods to manage video and documents conversion.
789
+
790
+ #### Convert a document
791
+
792
+ This method requires an UUID of a previously uploaded to Uploadcare file and target format.
793
+ If using an image format, you can also specify a page number that must be converted for a document containing pages.
794
+ More info about document conversion can be found [here](https://uploadcare.com/docs/transformations/document-conversion/).
795
+
796
+ ```console
797
+ $ Uploadcare::ConversionApi.convert_document(
798
+ $ { uuid: "466740dd-cfad-4de4-9218-1ddc0edf7aa6", format: "png", page: 1 },
799
+ $ store: false
800
+ $ )
801
+ # => Success({
802
+ # :result=>[{
803
+ # :original_source=>"466740dd-cfad-4de4-9218-1ddc0edf7aa6/document/-/format/png/-/page/1/",
804
+ # :token=>21316034,
805
+ # :uuid=>"db6e52b8-cc03-4174-a07a-012be43b144e"
806
+ # }],
807
+ # :problems=>{}
808
+ # })
809
+ ```
810
+
811
+
812
+ #### Get a document conversion job status
813
+
814
+ This method requires a token obtained in a response to the [convert_document](#convert-a-document) method.
815
+
816
+ ```console
817
+ $ Uploadcare::ConversionApi.get_document_conversion_status(21316034)
818
+ # => Success({
819
+ # :result=>{
820
+ # :uuid=>"db6e52b8-cc03-4174-a07a-012be43b144e"
821
+ # },
822
+ # :error=>nil,
823
+ # :status=>"finished"
824
+ # })
825
+ ```
826
+
827
+
828
+ #### Convert a video
829
+
830
+ Such as the document conversion method, this method requires an UUID of a previously uploaded to Uploadcare file.
831
+ Also you have several options to control the way a video will be converted. All of them are optional.
832
+ Description of valid options and other info about video conversion can be found [here](https://uploadcare.com/docs/transformations/video-encoding/).
833
+
834
+ ```console
835
+ $ Uploadcare::ConversionApi.convert_video(
836
+ $ {
837
+ $ uuid: "466740dd-cfad-4de4-9218-1ddc0edf7aa6",
838
+ $ format: "ogg",
839
+ $ quality: "best",
840
+ $ cut: { start_time: "0:0:0.0", length: "0:0:1.0" },
841
+ $ thumbs: { N: 2, number: 1 }
842
+ $ },
843
+ $ store: false
844
+ $ )
845
+ # => Success({
846
+ # :result=>[{
847
+ # :original_source=>"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/",
848
+ # :token=>916090555,
849
+ # :uuid=>"df597ef4-59e7-47ef-af5d-365d8409934c~2",
850
+ # :thumbnails_group_uuid=>"df597ef4-59e7-47ef-af5d-365d8409934c~2"
851
+ # }],
852
+ # :problems=>{}
853
+ # })
854
+ ```
855
+
856
+
857
+ #### Get a video conversion job status
858
+
859
+ This method requires a token obtained in a response to the [convert_video](#convert-a-video) method.
860
+
861
+ ```console
862
+ $ Uploadcare::ConversionApi.get_video_conversion_status(916090555)
863
+ # => Success({
864
+ # :result=>{
865
+ # :uuid=>"f0a3e66e-cd22-4397-ba0a-8a8becc925f9",
866
+ # :thumbnails_group_uuid=>"df597ef4-59e7-47ef-af5d-365d8409934c~2"
867
+ # },
868
+ # :error=>nil,
869
+ # :status=>"finished"
870
+ # })
871
+ ```
872
+
873
+
874
+ ### File Metadata Api
875
+
876
+ File metadata is additional, arbitrary data, associated with uploaded file.
877
+ As an example, you could store unique file identifier from your system.
878
+ Metadata is key-value data.
879
+
880
+ #### Get file's metadata keys and values
881
+
882
+ ```console
883
+ $ Uploadcare::FileMetadataApi.file_metadata('f757ea10-8b1a-4361-9a7c-56bfa5d45176')
884
+ # => {:"sample-key"=>"sample-value"}
885
+ ```
886
+
887
+ #### Get the value of a single metadata key
888
+
889
+ ```console
890
+ $ Uploadcare::FileMetadataApi.file_metadata_value('f757ea10-8b1a-4361-9a7c-56bfa5d45176', 'sample-key')
891
+ # => "sample-value"
892
+ ```
893
+
894
+ #### Update the value of a single metadata key
895
+
896
+ If the key does not exist, it will be created.
897
+
898
+ ```console
899
+ $ Uploadcare::FileMetadataApi.update_file_metadata('f757ea10-8b1a-4361-9a7c-56bfa5d45176', 'sample-key', 'new-value')
900
+ # => "new-value"
901
+ ```
902
+
903
+ #### Delete a file's metadata key
904
+
905
+ ```console
906
+ $ Uploadcare::FileMetadataApi.delete_file_metadata('f757ea10-8b1a-4361-9a7c-56bfa5d45176', 'sample-key')
907
+ # => "200 OK"
908
+ ```
909
+
910
+
911
+ ### Add-Ons Api
912
+
913
+ An 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.
914
+
915
+ #### Execute AWS Rekognition Add-On for a given target to detect labels in an image
916
+
917
+ ```
918
+ Note: Detected labels are stored in the file's appdata.
919
+ ```
920
+
921
+ ```console
922
+ $ Uploadcare::AddonsApi.rekognition_detect_labels('f757ea10-8b1a-4361-9a7c-56bfa5d45176')
923
+ # => {"request_id"=>"dfeaf81c-5c0d-49d5-8ed4-ac09bac7998e"}
924
+ ```
925
+
926
+ #### Check the status of an Add-On execution request that had been started using the Execute Add-On operation
927
+
928
+ ```console
929
+ $ Uploadcare::AddonsApi.rekognition_detect_labels_status('dfeaf81c-5c0d-49d5-8ed4-ac09bac7998e')
930
+ # => {"status"=>"done"}
931
+ ```
932
+
933
+ #### Execute ClamAV virus checking Add-On for a given target
934
+
935
+ ```console
936
+ $ Uploadcare::AddonsApi.virus_scan('dfeaf81c-5c0d-49d5-8ed4-ac09bac7998e')
937
+ # => {"request_id"=>"1b0126de-ace6-455b-82e2-25f4aa33fc6f"}
938
+ ```
939
+
940
+ #### Check the status of an Add-On execution request that had been started using the Execute Add-On operation
941
+
942
+ ```console
943
+ $ Uploadcare::AddonsApi.virus_scan_status('1b0126de-ace6-455b-82e2-25f4aa33fc6f')
944
+ # => {"status"=>"done"}
945
+ ```
946
+
947
+ #### Execute remove.bg background image removal Add-On for a given target
948
+
949
+ ```console
950
+ $ Uploadcare::AddonsApi.remove_bg('f757ea10-8b1a-4361-9a7c-56bfa5d45176')
951
+ # => {"request_id"=>"6d26a7d5-0955-4aeb-a9b1-c9776c83aa4c"}
952
+ ```
953
+
954
+ #### Check the status of an Add-On execution request that had been started using the Execute Add-On operation
955
+
956
+ ```console
957
+ $ Uploadcare::AddonsApi.remove_bg_status('6d26a7d5-0955-4aeb-a9b1-c9776c83aa4c')
958
+ # => {"status"=>"done", "result"=>{"file_id"=>"8f0a2a28-3ed7-481e-b415-ee3cce982aaa"}}
959
+ ```
960
+
961
+
962
+ ## Useful links
963
+ * [Uploadcare documentation](https://uploadcare.com/docs/?utm_source=github&utm_medium=referral&utm_campaign=uploadcare-rails)
964
+ * [Upload API reference](https://uploadcare.com/api-refs/upload-api/?utm_source=github&utm_medium=referral&utm_campaign=uploadcare-rails)
965
+ * [REST API reference](https://uploadcare.com/api-refs/rest-api/?utm_source=github&utm_medium=referral&utm_campaign=uploadcare-rails)
966
+ * [Changelog](./CHANGELOG.md)
967
+ * [Contributing guide](https://github.com/uploadcare/.github/blob/master/CONTRIBUTING.md)
968
+ * [Security policy](https://github.com/uploadcare/uploadcare-rails/security/policy)
969
+ * [Support](https://github.com/uploadcare/.github/blob/master/SUPPORT.md)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Uploadcare
4
4
  module Rails
5
- VERSION = '3.3.2'
5
+ VERSION = '3.3.2.1'
6
6
  end
7
7
  end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.push File.expand_path('lib', __dir__)
4
+
5
+ # Maintain your gem's version:
6
+ require 'uploadcare/rails/version'
7
+
8
+ # Describe your gem and declare its dependencies:
9
+ Gem::Specification.new do |gem|
10
+ gem.required_ruby_version = '>= 2.7.0'
11
+
12
+ gem.name = 'uploadcare-rails'
13
+ gem.authors = ['@dmitrijivanchenko (Dmitrij Ivanchenko), @T0mbery (Andrey Aksenov)',
14
+ 'kraft001 (Konstantin Rafalskii)']
15
+ gem.email = ['hello@uploadcare.com']
16
+ gem.summary = 'Rails gem for Uploadcare'
17
+ gem.description = <<~DESCRIPTION
18
+ Rails API client (based on uploadcare-ruby) that handles uploads
19
+ and further operations with files by wrapping Uploadcare Upload and REST APIs.
20
+ DESCRIPTION
21
+ gem.metadata = {
22
+ 'source_code_uri' => 'https://github.com/uploadcare/uploadcare-rails',
23
+ 'bug_tracker_uri' => 'https://github.com/uploadcare/uploadcare-rails/issues',
24
+ 'changelog_uri' => 'https://github.com/uploadcare/uploadcare-rails/blob/main/CHANGELOG.md',
25
+ 'documentation_uri' => 'https://www.rubydoc.info/gems/uploadcare-rails/',
26
+ 'homepage_uri' => 'https://uploadcare.com/',
27
+ 'rubygems_mfa_required' => 'true'
28
+ }
29
+ gem.homepage = 'https://uploadcare.com/'
30
+ gem.license = 'MIT'
31
+
32
+ gem.files = Dir[
33
+ 'lib/**/*',
34
+ 'Gemfile',
35
+ 'Rakefile',
36
+ 'uploadcare-rails.gemspec',
37
+ 'LICENSE.txt',
38
+ 'README.md',
39
+ 'CHANGELOG.md'
40
+ ]
41
+
42
+ gem.extra_rdoc_files = %w[README.md LICENSE.txt]
43
+ gem.rdoc_options = %w[--line-numbers --title Uploadcare --main README.rdoc --encoding=UTF-8]
44
+
45
+ gem.version = Uploadcare::Rails::VERSION
46
+ gem.add_dependency 'rails', '>= 6'
47
+ gem.add_dependency 'uploadcare-ruby', '>= 4.3'
48
+
49
+ gem.add_development_dependency 'rspec', '~> 3.12'
50
+ gem.add_development_dependency 'rspec-rails', '>= 5.1'
51
+ gem.add_development_dependency 'rubocop', '~> 1.48'
52
+ gem.add_development_dependency 'vcr', '~> 6.1'
53
+ gem.add_development_dependency 'webmock', '~> 3.18'
54
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uploadcare-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.2
4
+ version: 3.3.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - "@dmitrijivanchenko (Dmitrij Ivanchenko), @T0mbery (Andrey Aksenov)"
@@ -116,8 +116,14 @@ email:
116
116
  - hello@uploadcare.com
117
117
  executables: []
118
118
  extensions: []
119
- extra_rdoc_files: []
119
+ extra_rdoc_files:
120
+ - README.md
121
+ - LICENSE.txt
120
122
  files:
123
+ - CHANGELOG.md
124
+ - Gemfile
125
+ - LICENSE.txt
126
+ - README.md
121
127
  - Rakefile
122
128
  - lib/generators/templates/uploadcare_config_template.erb
123
129
  - lib/generators/uploadcare_config_generator.rb
@@ -150,16 +156,25 @@ files:
150
156
  - lib/uploadcare/rails/services/id_extractor.rb
151
157
  - lib/uploadcare/rails/transformations/image_transformations.rb
152
158
  - lib/uploadcare/rails/version.rb
153
- homepage: https://github.com/uploadcare/uploadcare-rails
159
+ - uploadcare-rails.gemspec
160
+ homepage: https://uploadcare.com/
154
161
  licenses:
155
162
  - MIT
156
163
  metadata:
157
- github: https://github.com/uploadcare/uploadcare-rails
164
+ source_code_uri: https://github.com/uploadcare/uploadcare-rails
158
165
  bug_tracker_uri: https://github.com/uploadcare/uploadcare-rails/issues
159
166
  changelog_uri: https://github.com/uploadcare/uploadcare-rails/blob/main/CHANGELOG.md
167
+ documentation_uri: https://www.rubydoc.info/gems/uploadcare-rails/
168
+ homepage_uri: https://uploadcare.com/
160
169
  rubygems_mfa_required: 'true'
161
170
  post_install_message:
162
- rdoc_options: []
171
+ rdoc_options:
172
+ - "--line-numbers"
173
+ - "--title"
174
+ - Uploadcare
175
+ - "--main"
176
+ - README.rdoc
177
+ - "--encoding=UTF-8"
163
178
  require_paths:
164
179
  - lib
165
180
  required_ruby_version: !ruby/object:Gem::Requirement