uploadcare-ruby 3.3.2 → 4.3.0

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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/gem-push.yml +4 -2
  3. data/.github/workflows/ruby.yml +11 -7
  4. data/.gitignore +6 -0
  5. data/.rubocop.yml +1 -0
  6. data/CHANGELOG.md +49 -0
  7. data/README.md +194 -37
  8. data/lib/uploadcare/client/addons_client.rb +56 -0
  9. data/lib/uploadcare/client/conversion/base_conversion_client.rb +2 -2
  10. data/lib/uploadcare/client/conversion/document_conversion_client.rb +1 -1
  11. data/lib/uploadcare/client/conversion/video_conversion_client.rb +1 -1
  12. data/lib/uploadcare/client/file_client.rb +14 -10
  13. data/lib/uploadcare/client/file_list_client.rb +4 -4
  14. data/lib/uploadcare/client/file_metadata_client.rb +36 -0
  15. data/lib/uploadcare/client/group_client.rb +5 -5
  16. data/lib/uploadcare/client/multipart_upload/chunks_client.rb +2 -1
  17. data/lib/uploadcare/client/multipart_upload_client.rb +5 -4
  18. data/lib/uploadcare/client/project_client.rb +1 -1
  19. data/lib/uploadcare/client/rest_client.rb +6 -6
  20. data/lib/uploadcare/client/rest_group_client.rb +24 -4
  21. data/lib/uploadcare/client/upload_client.rb +4 -1
  22. data/lib/uploadcare/client/uploader_client.rb +13 -12
  23. data/lib/uploadcare/client/webhook_client.rb +8 -8
  24. data/lib/uploadcare/concern/error_handler.rb +1 -1
  25. data/lib/uploadcare/concern/upload_error_handler.rb +1 -1
  26. data/lib/uploadcare/entity/addons.rb +14 -0
  27. data/lib/uploadcare/entity/conversion/base_converter.rb +1 -1
  28. data/lib/uploadcare/entity/decorator/paginator.rb +2 -2
  29. data/lib/uploadcare/entity/file.rb +20 -38
  30. data/lib/uploadcare/entity/file_list.rb +1 -0
  31. data/lib/uploadcare/entity/file_metadata.rb +30 -0
  32. data/lib/uploadcare/entity/group.rb +11 -2
  33. data/lib/uploadcare/entity/uploader.rb +13 -13
  34. data/lib/uploadcare/param/authentication_header.rb +2 -2
  35. data/lib/uploadcare/param/secure_auth_header.rb +3 -3
  36. data/lib/uploadcare/param/simple_auth_header.rb +1 -1
  37. data/lib/uploadcare/param/upload/signature_generator.rb +2 -2
  38. data/lib/uploadcare/param/upload/upload_params_generator.rb +25 -8
  39. data/lib/uploadcare/param/webhook_signature_verifier.rb +1 -1
  40. data/lib/uploadcare/ruby/version.rb +1 -1
  41. data/lib/uploadcare.rb +1 -0
  42. data/uploadcare-ruby.gemspec +11 -11
  43. metadata +46 -36
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d3c7c464a8d89a9451f4205ba7f82b3c270d2431eb2b9cf9e31f64fc0542e032
4
- data.tar.gz: 5ee0ef07f9194986eaf3742a5a80d01be38cd69a7e951551b791bcf479cf17f0
3
+ metadata.gz: cf8a5684245c373f5f84e4aa67daae89eab8202ffdee98e64468bffa1336832e
4
+ data.tar.gz: 10437f9330e348641c2e68507e1290b481c05cf7f8432a5fc02ea16979249914
5
5
  SHA512:
6
- metadata.gz: 6accbd5a9c9c593c252a370947f42756a477cb47d6d1261a54a17df6f7026f9dd5e49ded174718ce159e6f3da9638744c4520673cfc0c81dcac381f129de2016
7
- data.tar.gz: c383653917bab7dbc417eeccd16b800066ee07cf3741f3734361b8ae9da2935e369442711071a0ab0453860321b21a7a979265fa2a7f19daaaefb9fd4c5add20
6
+ metadata.gz: 79c53ddc0fad34527fce0c3d15362c6d18479bad625ccce2b127c97089bea4d650cc2fa5c698a76f534b2631aca356bfd4a829d1fc44f08ba466c76f2926eba1
7
+ data.tar.gz: 44ba70a98651ec3d764491335d754684634bb3ccff1719197ca6b0a9117bcef50b45bf9e8b2f09be2f85a151f60837216032c63f0a514caebf9afe5eb5e755a7
@@ -2,6 +2,8 @@ name: Publish Gem
2
2
 
3
3
  on:
4
4
  push:
5
+ branches:
6
+ - "*"
5
7
  tags:
6
8
  - v*
7
9
  jobs:
@@ -9,11 +11,11 @@ jobs:
9
11
  runs-on: ubuntu-latest
10
12
 
11
13
  steps:
12
- - uses: actions/checkout@v1
14
+ - uses: actions/checkout@v3
13
15
 
14
16
  - name: Release Gem
15
17
  if: contains(github.ref, 'refs/tags/v')
16
- uses: cadwallion/publish-rubygems-action@v1.0.0
18
+ uses: cadwallion/publish-rubygems-action@master
17
19
  env:
18
20
  GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
19
21
  RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
@@ -15,16 +15,18 @@ jobs:
15
15
  runs-on: ubuntu-latest
16
16
  strategy:
17
17
  matrix:
18
- ruby-version: [
19
- '2.4', '2.5', # eol
20
- '2.6', '2.7', # maintained
21
- ]
18
+ ruby-version:
19
+ - 2.7
20
+ - 3.0
21
+ - 3.1
22
+ - 3.2
22
23
 
23
24
  steps:
24
- - uses: actions/checkout@v2
25
+ - uses: actions/checkout@v3
25
26
  - name: Set up Ruby
26
27
  uses: ruby/setup-ruby@v1
27
28
  with:
29
+ bundler: 2.4
28
30
  ruby-version: ${{ matrix.ruby-version }}
29
31
  bundler-cache: true
30
32
  - name: Run tests
@@ -38,9 +40,11 @@ jobs:
38
40
  continue-on-error: true
39
41
  strategy:
40
42
  matrix:
41
- ruby-version: ['2.7',]
43
+ ruby-version:
44
+ - 2.7
45
+ - 3.2
42
46
  steps:
43
- - uses: actions/checkout@v2
47
+ - uses: actions/checkout@v3
44
48
  - name: Set up Ruby
45
49
  uses: ruby/setup-ruby@v1
46
50
  with:
data/.gitignore CHANGED
@@ -11,4 +11,10 @@
11
11
  # rspec failure tracking
12
12
  .rspec_status
13
13
  .byebug_history
14
+
15
+ .idea
14
16
  Gemfile.lock
17
+
18
+ .ruby-version
19
+ project_files
20
+ *.gem
data/.rubocop.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  AllCops:
2
+ NewCops: enable
2
3
  TargetRubyVersion: 2.7
3
4
 
4
5
  Metrics/LineLength:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,54 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.3.0 — 2023-03-15
4
+
5
+ Add support of new ruby versions
6
+
7
+ ### Breaking Сhanges
8
+
9
+ Drop support of unmaintainable Ruby versions (2.4, 2.5, 2.6).
10
+
11
+ ### Added
12
+
13
+ Add support for Ruby 3+ (3.0, 3.1, 3.2).
14
+
15
+ ## 4.0.0 — 2022-12-29
16
+
17
+ 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:
18
+ * [File metadata](https://uploadcare.com/docs/file-metadata/)
19
+ * New [add-ons API](https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/Add-Ons):
20
+ * [Background removal](https://uploadcare.com/docs/remove-bg/)
21
+ * [Virus checking](https://uploadcare.com/docs/security/malware-protection/)
22
+ * [Object recognition](https://uploadcare.com/docs/intelligence/object-recognition/)
23
+
24
+ ### Breaking Сhanges
25
+
26
+ - For `Uploadcare::File#info`
27
+ - File information doesn't return `image_info` and `video_info` fields anymore
28
+ - Removed `rekognition_info` in favor of `appdata`
29
+ - Parameter `add_fields` was renamed to `include`
30
+ - For `Uploadcare::FileList#file_list`
31
+ - Removed the option of sorting the file list by file size
32
+ - For `Uploadcare::Group#store`
33
+ - Changed response format
34
+ - For `Uploadcare::File`
35
+ - Removed method `copy` in favor of `local_copy` and `remote_copy` methods
36
+
37
+ ### Changed
38
+
39
+ - For `Uploadcare::File#info`
40
+ - Field `content_info` that includes mime-type, image (dimensions, format, etc), video information (duration, format, bitrate, etc), audio information, etc
41
+ - Field `metadata` that includes arbitrary metadata associated with a file
42
+ - Field `appdata` that includes dictionary of application names and data associated with these applications
43
+
44
+ ### Added
45
+
46
+ - Add Uploadcare API interface:
47
+ - `Uploadcare::FileMetadata`
48
+ - `Uploadcare::Addons`
49
+ - Added an option to delete a Group
50
+ - For `Uploadcare::File` add `local_copy` and `remote_copy` methods
51
+
3
52
  ## 3.3.2 - 2022-07-18
4
53
 
5
54
  - Fixes dry-configurable deprecation warnings
data/README.md CHANGED
@@ -25,15 +25,17 @@ wrapping Upload and REST APIs.
25
25
  * [File](#file)
26
26
  * [FileList](#filelist)
27
27
  * [Pagination](#pagination)
28
+ * [Custom File Metadata](#custom-file-metadata)
28
29
  * [Group](#group)
29
30
  * [GroupList](#grouplist)
30
31
  * [Webhook](#webhook)
32
+ * [Add-Ons](#add-ons)
31
33
  * [Project](#project)
32
34
  * [Conversion](#conversion)
33
35
  * [Useful links](#useful-links)
34
36
 
35
37
  ## Requirements
36
- * ruby 2.4+
38
+ * ruby 2.7+
37
39
 
38
40
  ## Compatibility
39
41
 
@@ -52,13 +54,19 @@ And then execute:
52
54
 
53
55
  $ bundle
54
56
 
57
+ If you use `api_struct` gem in your project, replace it with `uploadcare-api_struct`:
58
+ ```ruby
59
+ gem 'uploadcare-api_struct'
60
+ ```
61
+ and run `bundle install`
62
+
55
63
  If already not, create your project in [Uploadcare dashboard](https://app.uploadcare.com/?utm_source=github&utm_medium=referral&utm_campaign=uploadcare-ruby) and copy
56
- its API keys from there.
64
+ its [API keys](https://app.uploadcare.com/projects/-/api-keys/) from there.
57
65
 
58
66
  Set your Uploadcare keys in config file or through environment variables:
59
67
  ```bash
60
- export UPLOADCARE_PUBLIC_KEY=demopublickey
61
- export UPLOADCARE_SECRET_KEY=demoprivatekey
68
+ export UPLOADCARE_PUBLIC_KEY=your_public_key
69
+ export UPLOADCARE_SECRET_KEY=your_private_key
62
70
  ```
63
71
 
64
72
  Or configure your app yourself if you are using different way of storing keys.
@@ -67,8 +75,8 @@ settings can be seen in [`lib/uploadcare.rb`](lib/uploadcare.rb)
67
75
 
68
76
  ```ruby
69
77
  # your_config_initializer_file.rb
70
- Uploadcare.config.public_key = "demopublickey"
71
- Uploadcare.config.secret_key = "demoprivatekey"
78
+ Uploadcare.config.public_key = "your_public_key"
79
+ Uploadcare.config.secret_key = "your_private_key"
72
80
  ```
73
81
 
74
82
  ## Usage
@@ -143,7 +151,7 @@ After the request for uploading-from-URL is sent, you can check the progress of
143
151
 
144
152
  ```ruby
145
153
  Uploadcare::Uploader.get_upload_from_url_status("1251ee66-3631-4416-a2fb-96ba59f5a515")
146
- # => Success({:size=>28511, :total=>28511, :done=>28511, :uuid=>"b829753b-6b64-4989-a167-ef15e4f3d190", :file_id=>"b859753b-zb64-4989-a167-ef15e4f3a190", :original_filename=>"video.ogg", :is_image=>false, :is_stored=>false, :image_info=>nil, :video_info=>nil, :is_ready=>true, :filename=>"video.ogg", :mime_type=>"audio/ogg", :status=>"success"})
154
+ # => Success({:size=>453543, :total=>453543, :done=>453543, :uuid=>"5c51a7fe-e45d-42a2-ba5e-79957ff4bdab", :file_id=>"5c51a7fe-e45d-42a2-ba5e-79957ff4bdab", :original_filename=>"2250", :is_image=>true, :is_stored=>false, :image_info=>{:dpi=>[96, 96], :width=>2250, :format=>"JPEG", :height=>2250, :sequence=>false, :color_mode=>"RGB", :orientation=>nil, :geo_location=>nil, :datetime_original=>nil}, :video_info=>nil, :content_info=>{:mime=>{:mime=>"image/jpeg", :type=>"image", :subtype=>"jpeg"}, :image=>{:dpi=>[96, 96], :width=>2250, :format=>"JPEG", :height=>2250, :sequence=>false, :color_mode=>"RGB", :orientation=>nil, :geo_location=>nil, :datetime_original=>nil}}, :is_ready=>true, :filename=>"2250", :mime_type=>"image/jpeg", :metadata=>{}, :status=>"success"})
147
155
  ```
148
156
 
149
157
  In case of the `async` option is disabled, uploadcare-ruby tries to request the upload status several times (depending on the `max_request_tries` config param) and then returns uploaded file attributes.
@@ -188,6 +196,13 @@ You can override global [`:autostore`](#initialization) option for each upload r
188
196
  @api.upload_from_url(url, store: :auto)
189
197
  ```
190
198
 
199
+ You can upload file with custom metadata, for example `subsystem` and `pet`:
200
+
201
+ ```ruby
202
+ @api.upload(files, metadata: { subsystem: 'my_subsystem', pet: 'cat' } )
203
+ @api.upload_from_url(url, metadata: { subsystem: 'my_subsystem', pet: 'cat' })
204
+ ```
205
+
191
206
  ### File management
192
207
 
193
208
  Entities are representations of objects in Uploadcare cloud.
@@ -198,31 +213,107 @@ File entity contains its metadata.
198
213
 
199
214
  ```ruby
200
215
  @file = Uploadcare::File.file("FILE_ID_IN_YOUR_PROJECT")
201
- {"datetime_removed"=>nil,
202
- "datetime_stored"=>"2020-01-16T15:03:15.315064Z",
203
- "datetime_uploaded"=>"2020-01-16T15:03:14.676902Z",
204
- "image_info"=>
205
- {"color_mode"=>"RGB",
206
- "orientation"=>nil,
207
- "format"=>"JPEG",
208
- "sequence"=>false,
209
- "height"=>183,
210
- "width"=>190,
211
- "geo_location"=>nil,
212
- "datetime_original"=>nil,
213
- "dpi"=>nil},
214
- "is_image"=>true,
215
- "is_ready"=>true,
216
- "mime_type"=>"image/jpeg",
217
- "original_file_url"=>
218
- "https://ucarecdn.com/FILE_ID_IN_YOUR_PROJECT/imagepng.jpeg",
219
- "original_filename"=>"image.png.jpeg",
220
- "size"=>5345,
221
- "url"=>
222
- "https://api.uploadcare.com/files/FILE_ID_IN_YOUR_PROJECT/",
223
- "uuid"=>"8f64f313-e6b1-4731-96c0-6751f1e7a50a"}
224
-
225
- @file.copy # copies file, returns a new (copied) file metadata
216
+ {
217
+ "datetime_removed"=>nil,
218
+ "datetime_stored"=>"2018-11-26T12:49:10.477888Z",
219
+ "datetime_uploaded"=>"2018-11-26T12:49:09.945335Z",
220
+ "is_image"=>true,
221
+ "is_ready"=>true,
222
+ "mime_type"=>"image/jpeg",
223
+ "original_file_url"=>"https://ucarecdn.com/FILE_ID_IN_YOUR_PROJECT/pineapple.jpg",
224
+ "original_filename"=>"pineapple.jpg",
225
+ "size"=>642,
226
+ "url"=>"https://api.uploadcare.com/files/FILE_ID_IN_YOUR_PROJECT/",
227
+ "uuid"=>"FILE_ID_IN_YOUR_PROJECT",
228
+ "variations"=>nil,
229
+ "content_info"=>{
230
+ "mime"=>{
231
+ "mime"=>"image/jpeg",
232
+ "type"=>"image",
233
+ "subtype"=>"jpeg"
234
+ },
235
+ "image"=>{
236
+ "format"=>"JPEG",
237
+ "width"=>500,
238
+ "height"=>500,
239
+ "sequence"=>false,
240
+ "orientation"=>6,
241
+ "geo_location"=>{
242
+ "latitude"=>55.62013611111111,
243
+ "longitude"=>37.66299166666666
244
+ },
245
+ "datetime_original"=>"2018-08-20T08:59:50",
246
+ "dpi"=>[72, 72]
247
+ }
248
+ },
249
+ "metadata"=>{
250
+ "subsystem"=>"uploader",
251
+ "pet"=>"cat"
252
+ },
253
+ "appdata"=>{
254
+ "uc_clamav_virus_scan"=>{
255
+ "data"=>{
256
+ "infected"=>true,
257
+ "infected_with"=>"Win.Test.EICAR_HDB-1"
258
+ },
259
+ "version"=>"0.104.2",
260
+ "datetime_created"=>"2021-09-21T11:24:33.159663Z",
261
+ "datetime_updated"=>"2021-09-21T11:24:33.159663Z"
262
+ },
263
+ "remove_bg"=>{
264
+ "data"=>{
265
+ "foreground_type"=>"person"
266
+ },
267
+ "version"=>"1.0",
268
+ "datetime_created"=>"2021-07-25T12:24:33.159663Z",
269
+ "datetime_updated"=>"2021-07-25T12:24:33.159663Z"
270
+ },
271
+ "aws_rekognition_detect_labels"=>{
272
+ "data"=>{
273
+ "LabelModelVersion"=>"2.0",
274
+ "Labels"=>[
275
+ {
276
+ "Confidence"=>93.41645812988281,
277
+ "Instances"=>[],
278
+ "Name"=>"Home Decor",
279
+ "Parents"=>[]
280
+ },
281
+ {
282
+ "Confidence"=>70.75951385498047,
283
+ "Instances"=>[],
284
+ "Name"=>"Linen",
285
+ "Parents"=>[{ "Name"=>"Home Decor" }]
286
+ },
287
+ {
288
+ "Confidence"=>64.7123794555664,
289
+ "Instances"=>[],
290
+ "Name"=>"Sunlight",
291
+ "Parents"=>[]
292
+ },
293
+ {
294
+ "Confidence"=>56.264793395996094,
295
+ "Instances"=>[],
296
+ "Name"=>"Flare",
297
+ "Parents"=>[{ "Name"=>"Light" }]
298
+ },
299
+ {
300
+ "Confidence"=>50.47153854370117,
301
+ "Instances"=>[],
302
+ "Name"=>"Tree",
303
+ "Parents"=>[{ "Name"=>"Plant" }]
304
+ }
305
+ ]
306
+ },
307
+ "version"=>"2016-06-27",
308
+ "datetime_created"=>"2021-09-21T11:25:31.259763Z",
309
+ "datetime_updated"=>"2021-09-21T11:27:33.359763Z"
310
+ }
311
+ }
312
+ }
313
+
314
+ @file.local_copy # copy file to local storage
315
+
316
+ @file.remote_copy # copy file to remote storage
226
317
 
227
318
  @file.store # stores file, returns updated metadata
228
319
 
@@ -300,8 +391,8 @@ how they should be fetched:
300
391
  - **:limit** — Controls page size. Accepts values from 1 to 1000, defaults to 100.
301
392
  - **:stored** — Can be either `true` or `false`. When true, file list will contain only stored files. When false — only not stored.
302
393
  - **:removed** — Can be either `true` or `false`. When true, file list will contain only removed files. When false — all except removed. Defaults to false.
303
- - **:ordering** — Controls the order of returned files. Available values: `datetime_updated`, `-datetime_updated`, `size`, `-size`. Defaults to `datetime_uploaded`. More info can be found [here](https://uploadcare.com/api-refs/rest-api/v0.6.0/#operation/filesList).
304
- - **:from** — Specifies the starting point for a collection. Resulting collection will contain files from the given value and to the end in a direction set by an **ordering** option. When files are ordered by `datetime_updated` in any direction, accepts either a `DateTime` object or an ISO 8601 string. When files are ordered by size, accepts non-negative integers (size in bytes). More info can be found [here](https://uploadcare.com/api-refs/rest-api/v0.6.0/#operation/filesList).
394
+ - **:ordering** — Controls the order of returned files. Available values: `datetime_uploaded`, `-datetime_uploaded`. Defaults to `datetime_uploaded`. More info can be found [here](https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/filesList).
395
+ - **:from** — Specifies the starting point for a collection. Resulting collection will contain files from the given value and to the end in a direction set by an **ordering** option. When files are ordered by `datetime_updated` in any direction, accepts either a `DateTime` object or an ISO 8601 string. When files are ordered by size, accepts non-negative integers (size in bytes). More info can be found [here](https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/filesList).
305
396
 
306
397
  Options used to create a file list can be accessed through `#options` method.
307
398
  Note that, once set, they don't affect file fetching process anymore and are
@@ -340,6 +431,25 @@ Alternatively, it's possible to iterate through full list of groups or files wit
340
431
  end
341
432
  ```
342
433
 
434
+ #### Custom File Metadata
435
+
436
+ File metadata is additional, arbitrary data, associated with uploaded file.
437
+ As an example, you could store unique file identifier from your system.
438
+
439
+ ```ruby
440
+ # Get file's metadata keys and values.
441
+ Uploadcare::FileMetadata.index('FILE_ID_IN_YOUR_PROJECT')
442
+
443
+ # Get the value of a single metadata key.
444
+ Uploadcare::FileMetadata.show('FILE_ID_IN_YOUR_PROJECT', 'KEY')
445
+
446
+ # Update the value of a single metadata key. If the key does not exist, it will be created.
447
+ Uploadcare::FileMetadata.update('FILE_ID_IN_YOUR_PROJECT', 'KEY', 'VALUE')
448
+
449
+ # Delete a file's metadata key.
450
+ Uploadcare::FileMetadata.delete('FILE_ID_IN_YOUR_PROJECT', 'KEY')
451
+ ```
452
+
343
453
  #### Group
344
454
 
345
455
  Groups are structures intended to organize sets of separate files. Each group is
@@ -355,6 +465,12 @@ That's a requirement of our API.
355
465
 
356
466
  # group can be stored by group ID. It means that all files of a group will be stored on Uploadcare servers permanently
357
467
  Uploadcare::Group.store(group.id)
468
+
469
+ # get a file group by its ID.
470
+ Uploadcare::Group.rest_info(group.id)
471
+
472
+ # group can be deleted by group ID.
473
+ Uploadcare::Group.delete(group.id)
358
474
  ```
359
475
 
360
476
  #### GroupList
@@ -430,15 +546,56 @@ else
430
546
  end
431
547
  ```
432
548
 
549
+ #### Add-Ons
550
+
551
+ 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.
552
+
553
+ ##### AWS Rekognition
554
+
555
+ ```ruby
556
+ # Execute AWS Rekognition Add-On for a given target to detect labels in an image. Note: Detected labels are stored in the file's appdata.
557
+ Uploadcare::Addons.ws_rekognition_detect_labels('FILE_ID_IN_YOUR_PROJECT')
558
+
559
+ # Check the status of AWS Rekognition.
560
+ Uploadcare::Addons.ws_rekognition_detect_labels_status('RETURNED_ID_FROM_WS_REKOGNITION_DETECT_LABELS')
561
+ ```
562
+
563
+ ##### ClamAV
564
+
565
+ ```ruby
566
+ # ClamAV virus checking Add-On for a given target.
567
+ Uploadcare::Addons.uc_clamav_virus_scan('FILE_ID_IN_YOUR_PROJECT')
568
+
569
+ # Checking and purge infected file.
570
+ Uploadcare::Addons.uc_clamav_virus_scan('FILE_ID_IN_YOUR_PROJECT', purge_infected: true )
571
+
572
+ # Check the status ClamAV virus scan.
573
+ Uploadcare::Addons.uc_clamav_virus_scan_status('RETURNED_ID_FROM_UC_CLAMAV_VIRUS_SCAN')
574
+ ```
575
+
576
+ ##### Remove.bg
577
+
578
+ ```ruby
579
+ # Remove background image removal Add-On for a given target.
580
+ Uploadcare::Addons.remove_bg('FILE_ID_IN_YOUR_PROJECT')
581
+
582
+ # You can pass optional parameters.
583
+ # See the full list of parameters here: https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/removeBgExecute
584
+ Uploadcare::Addons.remove_bg('FILE_ID_IN_YOUR_PROJECT', crop: true, type_level: '2')
585
+
586
+ # Check the status of background image removal.
587
+ Uploadcare::Addons.remove_bg_status('RETURNED_ID_FROM_REMOVE_BG')
588
+ ```
589
+
433
590
  #### Project
434
591
 
435
592
  `Project` provides basic info about the connected Uploadcare project. That
436
593
  object is also an Hashie::Mash, so every methods out of
437
- [these](https://uploadcare.com/api-refs/rest-api/v0.6.0/#operation/projectInfo) will work.
594
+ [these](https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/projectInfo) will work.
438
595
 
439
596
  ```ruby
440
597
  @project = Uploadcare::Project.project
441
- # => #<Uploadcare::Api::Project collaborators=[], name="demo", pub_key="demopublickey", autostore_enabled=true>
598
+ # => #<Uploadcare::Api::Project collaborators=[], name="demo", pub_key="your_public_key", autostore_enabled=true>
442
599
 
443
600
  @project.name
444
601
  # => "demo"
@@ -513,7 +670,7 @@ Params in the response:
513
670
  - **original_source** - built path for a particular video with all the conversion operations and parameters.
514
671
  - **token** - a processing job token that can be used to get a [job status](https://uploadcare.com/docs/transformations/video-encoding/#status) (see below).
515
672
  - **uuid** - UUID of your processed video file.
516
- - **thumbnails_group_uuid** - holds :uuid-thumb-group, a UUID of a [file group](https://uploadcare.com/api-refs/rest-api/v0.6.0/#operation/groupsList) with thumbnails for an output video, based on the thumbs [operation](https://uploadcare.com/docs/transformations/video-encoding/#operation-thumbs) parameters.
673
+ - **thumbnails_group_uuid** - holds :uuid-thumb-group, a UUID of a [file group](https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/groupsList) with thumbnails for an output video, based on the thumbs [operation](https://uploadcare.com/docs/transformations/video-encoding/#operation-thumbs) parameters.
517
674
  - **problems** - problems related to your processing job, if any.
518
675
 
519
676
  To convert multiple videos just add params as a hash for each video to the first argument of the `Uploadcare::VideoConverter#convert` method:
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'rest_client'
4
+
5
+ module Uploadcare
6
+ module Client
7
+ # API client for handling uploaded files
8
+ # @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/Add-Ons
9
+ class AddonsClient < RestClient
10
+ # Execute ClamAV virus checking Add-On for a given target.
11
+ # @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/ucClamavVirusScanExecute
12
+ def uc_clamav_virus_scan(uuid, params = {})
13
+ content = { target: uuid, params: params }.to_json
14
+ post(uri: '/addons/uc_clamav_virus_scan/execute/', content: content)
15
+ end
16
+
17
+ # Check the status of an Add-On execution request that had been started using the Execute Add-On operation.
18
+ # @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/ucClamavVirusScanExecutionStatus
19
+ def uc_clamav_virus_scan_status(uuid)
20
+ get(uri: "/addons/uc_clamav_virus_scan/execute/status/#{query_params(uuid)}")
21
+ end
22
+
23
+ # Execute AWS Rekognition Add-On for a given target to detect labels in an image.
24
+ # @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/awsRekognitionExecute
25
+ def ws_rekognition_detect_labels(uuid)
26
+ content = { target: uuid }.to_json
27
+ post(uri: '/addons/aws_rekognition_detect_labels/execute/', content: content)
28
+ end
29
+
30
+ # Check the status of an Add-On execution request that had been started using the Execute Add-On operation.
31
+ # @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/awsRekognitionExecutionStatus
32
+ def ws_rekognition_detect_labels_status(uuid)
33
+ get(uri: "/addons/aws_rekognition_detect_labels/execute/status/#{query_params(uuid)}")
34
+ end
35
+
36
+ # Execute remove.bg background image removal Add-On for a given target.
37
+ # @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/removeBgExecute
38
+ def remove_bg(uuid, params = {})
39
+ content = { target: uuid, params: params }.to_json
40
+ post(uri: '/addons/remove_bg/execute/', content: content)
41
+ end
42
+
43
+ # Check the status of an Add-On execution request that had been started using the Execute Add-On operation.
44
+ # @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/removeBgExecutionStatus
45
+ def remove_bg_status(uuid)
46
+ get(uri: "/addons/remove_bg/execute/status/#{query_params(uuid)}")
47
+ end
48
+
49
+ private
50
+
51
+ def query_params(uuid)
52
+ "?#{URI.encode_www_form(request_id: uuid)}"
53
+ end
54
+ end
55
+ end
56
+ end
@@ -8,14 +8,14 @@ module Uploadcare
8
8
  module Conversion
9
9
  # This is a base client for conversion operations
10
10
  #
11
- # @see https://uploadcare.com/api-refs/rest-api/v0.6.0/#tag/Conversion
11
+ # @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/Conversion
12
12
  class BaseConversionClient < RestClient
13
13
  API_VERSION_HEADER_VALUE = 'application/vnd.uploadcare-v0.5+json'
14
14
 
15
15
  def headers
16
16
  {
17
17
  'Content-Type': 'application/json',
18
- 'Accept': API_VERSION_HEADER_VALUE,
18
+ Accept: API_VERSION_HEADER_VALUE,
19
19
  'User-Agent': Uploadcare::Param::UserAgent.call
20
20
  }
21
21
  end
@@ -8,7 +8,7 @@ module Uploadcare
8
8
  module Conversion
9
9
  # This is client for document conversion
10
10
  #
11
- # @see https://uploadcare.com/api-refs/rest-api/v0.6.0/#operation/documentConvert
11
+ # @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/documentConvert
12
12
  class DocumentConversionClient < BaseConversionClient
13
13
  def convert_many(
14
14
  arr,
@@ -9,7 +9,7 @@ module Uploadcare
9
9
  module Conversion
10
10
  # This is client for video conversion
11
11
  #
12
- # @see https://uploadcare.com/api-refs/rest-api/v0.6.0/#operation/videoConvert
12
+ # @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/videoConvert
13
13
  class VideoConversionClient < BaseConversionClient
14
14
  def convert_many(
15
15
  params,
@@ -6,7 +6,7 @@ module Uploadcare
6
6
  module Client
7
7
  # API client for handling single files
8
8
  # @see https://uploadcare.com/docs/api_reference/rest/accessing_files/
9
- # @see https://uploadcare.com/api-refs/rest-api/v0.5.0/#tag/File
9
+ # @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/File
10
10
  class FileClient < RestClient
11
11
  # Gets list of files without pagination fields
12
12
  def index
@@ -15,27 +15,31 @@ module Uploadcare
15
15
  end
16
16
 
17
17
  # Acquire file info
18
- # @see https://uploadcare.com/api-refs/rest-api/v0.5.0/#operation/fileInfo
18
+ # @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/fileInfo
19
19
  def info(uuid)
20
20
  get(uri: "/files/#{uuid}/")
21
21
  end
22
22
  alias file info
23
23
 
24
- # 'copy' method is used to copy original files or their modified versions to default storage.
25
- # Source files MAY either be stored or just uploaded and MUST NOT be deleted.
26
- # @see https://uploadcare.com/api-refs/rest-api/v0.5.0/#operation/copyFile
27
- def copy(**options)
24
+ # @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/File/operation/createLocalCopy
25
+ def local_copy(options = {})
28
26
  body = options.compact.to_json
29
- post(uri: '/files/', content: body)
27
+ post(uri: '/files/local_copy/', content: body)
30
28
  end
31
29
 
32
- # @see https://uploadcare.com/api-refs/rest-api/v0.5.0/#operation/deleteFile
30
+ # @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/File/operation/createRemoteCopy
31
+ def remote_copy(options = {})
32
+ body = options.compact.to_json
33
+ post(uri: '/files/remote_copy/', content: body)
34
+ end
35
+
36
+ # @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/deleteFileStorage
33
37
  def delete(uuid)
34
- request(method: 'DELETE', uri: "/files/#{uuid}/")
38
+ request(method: 'DELETE', uri: "/files/#{uuid}/storage/")
35
39
  end
36
40
 
37
41
  # Store a single file, preventing it from being deleted in 2 weeks
38
- # @see https://uploadcare.com/api-refs/rest-api/v0.5.0/#operation/storeFile
42
+ # @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/storeFile
39
43
  def store(uuid)
40
44
  put(uri: "/files/#{uuid}/storage/")
41
45
  end
@@ -7,13 +7,13 @@ module Uploadcare
7
7
  # API client for handling file lists
8
8
  class FileListClient < RestClient
9
9
  # Returns a pagination json of files stored in project
10
- # @see https://uploadcare.com/api-refs/rest-api/v0.5.0/#operation/filesList
10
+ # @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/filesList
11
11
  #
12
12
  # valid options:
13
13
  # removed: [true|false]
14
14
  # stored: [true|false]
15
15
  # limit: (1..1000)
16
- # ordering: ["datetime_uploaded"|"-datetime_uploaded"|"size"|"-size"]
16
+ # ordering: ["datetime_uploaded"|"-datetime_uploaded"]
17
17
  # from: number of files skipped
18
18
  def file_list(options = {})
19
19
  query = options.empty? ? '' : "?#{URI.encode_www_form(options)}"
@@ -21,7 +21,7 @@ module Uploadcare
21
21
  end
22
22
 
23
23
  # Make a set of files "stored". This will prevent them from being deleted automatically
24
- # @see https://uploadcare.com/api-refs/rest-api/v0.5.0/#operation/filesStoring
24
+ # @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/filesStoring
25
25
  # uuids: Array
26
26
  def batch_store(uuids)
27
27
  body = uuids.to_json
@@ -31,7 +31,7 @@ module Uploadcare
31
31
  alias request_delete delete
32
32
 
33
33
  # Delete several files by list of uids
34
- # @see https://uploadcare.com/api-refs/rest-api/v0.5.0/#operation/filesDelete
34
+ # @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/filesDelete
35
35
  # uuids: Array
36
36
  def batch_delete(uuids)
37
37
  body = uuids.to_json