uploadcare-rails 3.4.1 → 3.4.3
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 +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +191 -125
- data/lib/uploadcare/rails/api/rest/addons_api.rb +12 -0
- data/lib/uploadcare/rails/api/rest/conversion_api.rb +6 -0
- data/lib/uploadcare/rails/version.rb +1 -1
- data/uploadcare-rails.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2138498faa17ca9479a74350760f49ac47057937a5863015aa15c9232f4fb7cc
|
4
|
+
data.tar.gz: cec22cbf947bf7fb913f1a8d682e6b88e6523854e6df7240482b9bbaaf6e6bc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be25b79f736dcd797f40a366f703cb62b78fa314ccd2352f4a5eb8a8660396f1b1253c638ec4f5a3be750ef26326148f65ffefee6755d054db04484fb5dbc597
|
7
|
+
data.tar.gz: 47762243287e5bf267f645b67f69b89d9083560d3c9ae55899c918487df5994be0725c7a1168634bc96072a21db13ce485b4ea1f344c7421b1003e504da5822d
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based now on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## 3.4.3 — 2024-06-01
|
8
|
+
|
9
|
+
### Added
|
10
|
+
* For `Uploadcare::ConversionApi` added `get_document_conversion_formats_info` method to get the possible document conversion formats.
|
11
|
+
|
12
|
+
## 3.4.2 — 2024-05-11
|
13
|
+
|
14
|
+
### Added
|
15
|
+
* Added API support for `AWS Rekognition Moderation` Add-On.
|
16
|
+
|
7
17
|
## 3.4.1 — 2024-03-24
|
8
18
|
|
9
19
|
### Fixed
|
data/README.md
CHANGED
@@ -284,6 +284,50 @@ The value will be available in the controller by `params[:post][:picture]`.
|
|
284
284
|
|
285
285
|
The helper is detecting the value of the `multiple` property based on the mount type in your model.
|
286
286
|
|
287
|
+
### Caching issues with Turbolinks/Hotwire
|
288
|
+
|
289
|
+
If 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:
|
290
|
+
|
291
|
+
```
|
292
|
+
document.addEventListener('turbolinks:before-cache', function() {
|
293
|
+
const dialogClose = document.querySelector('.uploadcare--dialog__close');
|
294
|
+
if (dialogClose) {
|
295
|
+
dialogClose.dispatchEvent(new Event('click'));
|
296
|
+
}
|
297
|
+
|
298
|
+
const dialog = document.querySelector('.uploadcare--dialog');
|
299
|
+
if (dialog) {
|
300
|
+
dialog.remove();
|
301
|
+
}
|
302
|
+
|
303
|
+
const widgets = document.querySelectorAll('.uploadcare--widget');
|
304
|
+
widgets.forEach(widget => {
|
305
|
+
widget.remove();
|
306
|
+
});
|
307
|
+
});
|
308
|
+
```
|
309
|
+
|
310
|
+
Similarly if you are using [Hotwire](https://hotwired.dev/) then use can you use below code:
|
311
|
+
|
312
|
+
```
|
313
|
+
document.addEventListener('turbo:before-cache', function() {
|
314
|
+
const dialogClose = document.querySelector('.uploadcare--dialog__close');
|
315
|
+
if (dialogClose) {
|
316
|
+
dialogClose.dispatchEvent(new Event('click'));
|
317
|
+
}
|
318
|
+
|
319
|
+
const dialog = document.querySelector('.uploadcare--dialog');
|
320
|
+
if (dialog) {
|
321
|
+
dialog.remove();
|
322
|
+
}
|
323
|
+
|
324
|
+
const widgets = document.querySelectorAll('.uploadcare--widget');
|
325
|
+
widgets.forEach(widget => {
|
326
|
+
widget.remove();
|
327
|
+
});
|
328
|
+
});
|
329
|
+
```
|
330
|
+
|
287
331
|
### File and Group wrappers
|
288
332
|
|
289
333
|
When you mount either Uploadcare File or Group to an attribute, this attribute is getting wrapped with
|
@@ -302,48 +346,49 @@ end
|
|
302
346
|
|
303
347
|
And then you create a new Post object specifying a CDN-url for your previously uploaded Uploadcare file:
|
304
348
|
|
305
|
-
```
|
306
|
-
|
349
|
+
```ruby
|
350
|
+
post = Post.create(picture: "https://ucarecdn.com/2d33999d-c74a-4ff9-99ea-abc23496b052/")
|
307
351
|
```
|
308
352
|
|
309
353
|
Now the `post.picture` is an Uploadcare::Rails::File. Following methods are supported:
|
310
354
|
|
311
|
-
```
|
355
|
+
```ruby
|
312
356
|
# Store the file on an Uploadcare server permanently:
|
313
|
-
|
357
|
+
post.picture.store
|
314
358
|
# => {
|
315
359
|
# "cdn_url"=>"https://ucarecdn.com/2d33999d-c74a-4ff9-99ea-abc23496b052/",
|
316
360
|
# ...other group data...
|
317
361
|
# }
|
318
|
-
|
362
|
+
|
363
|
+
#
|
319
364
|
# Delete the file from an Uploadcare server permanently:
|
320
|
-
|
365
|
+
post.picture.delete
|
321
366
|
# => {
|
322
367
|
# "datetime_removed"=>"2021-07-30T09:19:30.797174Z",
|
323
368
|
# ...other group data...
|
324
369
|
# }
|
325
|
-
|
370
|
+
|
326
371
|
# Get CDN-url of an object attribute:
|
327
|
-
|
372
|
+
post.picture.to_s
|
328
373
|
# => "https://ucarecdn.com/2d33999d-c74a-4ff9-99ea-abc23496b052/"
|
329
|
-
|
374
|
+
|
330
375
|
# Load object (send a GET request to the server to get all the file's data)
|
331
376
|
# This data will be cached if the cache_files option is set to true
|
332
377
|
# Default data (without asking an Uploadcare server) for each file contains cdn_url and uuid only:
|
333
|
-
|
378
|
+
post.picture.load
|
334
379
|
# => {
|
335
380
|
# "cdn_url"=>"https://ucarecdn.com/2d33999d-c74a-4ff9-99ea-abc23496b052/",
|
336
381
|
# ...other file data...
|
337
382
|
# }
|
338
|
-
|
383
|
+
|
339
384
|
# Check if an attribute loaded from the server.
|
340
385
|
# Will return false unless the :load or the :store methods are called:
|
341
|
-
|
386
|
+
post.picture.loaded?
|
342
387
|
# => true
|
343
|
-
|
388
|
+
|
344
389
|
# More about image transformations below.
|
345
390
|
# Transform a CDN-url to get a new transformed image's source. Works for images only:
|
346
|
-
|
391
|
+
post.picture.transform_url(quality: "better")
|
347
392
|
# => "https://ucarecdn.com/2d33999d-c74a-4ff9-99ea-abc23496b052/-/quality/better/"
|
348
393
|
```
|
349
394
|
|
@@ -360,15 +405,15 @@ end
|
|
360
405
|
|
361
406
|
Creating a new `post` with the Group mounted:
|
362
407
|
|
363
|
-
```
|
364
|
-
|
408
|
+
```ruby
|
409
|
+
post = Post.create(attachments: "https://ucarecdn.com/dbc4e868-b7a6-43ff-a35f-2ebef935dc1b~1/")
|
365
410
|
```
|
366
411
|
|
367
412
|
Now the `post.attachments` is an Uploadcare::Rails::Group. Following methods are supported:
|
368
413
|
|
369
|
-
```
|
414
|
+
```ruby
|
370
415
|
# Store the file group on an Uploadcare server permanently:
|
371
|
-
|
416
|
+
post.attachments.store
|
372
417
|
# => {
|
373
418
|
# "cdn_url"=>"https://ucarecdn.com/dbc4e868-b7a6-43ff-a35f-2ebef935dc1b~1/",
|
374
419
|
# ...other group data...
|
@@ -377,20 +422,21 @@ $ post.attachments.store
|
|
377
422
|
# ...other file data...
|
378
423
|
# }]
|
379
424
|
# }
|
380
|
-
|
425
|
+
|
426
|
+
#
|
381
427
|
# Delete the file group from an Uploadcare server permanently:
|
382
|
-
|
428
|
+
post.attachments.delete
|
383
429
|
# => {
|
384
430
|
# "datetime_removed"=>"2021-07-30T09:19:30.797174Z",
|
385
431
|
# ...other group data...
|
386
432
|
# }
|
387
|
-
|
433
|
+
|
388
434
|
# Get CDN-url of an object attribute:
|
389
|
-
|
435
|
+
post.attachments.to_s
|
390
436
|
# => "https://ucarecdn.com/dbc4e868-b7a6-43ff-a35f-2ebef935dc1b~1/"
|
391
|
-
|
437
|
+
|
392
438
|
# Load object — works the same way as for the File:
|
393
|
-
|
439
|
+
post.attachments.load
|
394
440
|
# => {
|
395
441
|
# "cdn_url"=>"https://ucarecdn.com/dbc4e868-b7a6-43ff-a35f-2ebef935dc1b~1/",
|
396
442
|
# ...other group data...
|
@@ -399,19 +445,19 @@ $ post.attachments.load
|
|
399
445
|
# ...other file data...
|
400
446
|
# }]
|
401
447
|
# }
|
402
|
-
|
448
|
+
|
403
449
|
# Check if an attribute loaded from the server:
|
404
|
-
|
450
|
+
post.attachments.loaded?
|
405
451
|
# => true
|
406
|
-
|
452
|
+
|
407
453
|
# As we don't want to show (on the html-page) a file group itself,
|
408
454
|
# we can get CDN-urls for file that the group contains. No loading group or files needed.
|
409
455
|
# This works for images only:
|
410
|
-
|
456
|
+
post.attachments.transform_file_urls(quality: "better")
|
411
457
|
# => ["https://ucarecdn.com/dbc4e868-b7a6-43ff-a35f-2ebef935dc1b~1/nth/0/-/quality/better/"]
|
412
|
-
|
458
|
+
|
413
459
|
# If you want to get non-transformed file urls, use:
|
414
|
-
|
460
|
+
post.attachments.file_urls
|
415
461
|
# => ["https://ucarecdn.com/dbc4e868-b7a6-43ff-a35f-2ebef935dc1b~1/nth/0/"]
|
416
462
|
```
|
417
463
|
|
@@ -421,15 +467,15 @@ $ post.attachments.file_urls
|
|
421
467
|
Uploadcare provides a way to transform images stored on Uploadcare services specifying a list of operations.
|
422
468
|
If an operation has just one option, you can specify it like key-value:
|
423
469
|
|
424
|
-
```
|
425
|
-
|
470
|
+
```ruby
|
471
|
+
post.picture.transform_url(quality: "better")
|
426
472
|
# => "https://ucarecdn.com/ebbb9929-eb92-4f52-a212-eecfdb19d27d/-/quality/better/"
|
427
473
|
```
|
428
474
|
|
429
475
|
and if an operation supports several options — just set them as a Hash:
|
430
476
|
|
431
|
-
```
|
432
|
-
|
477
|
+
```ruby
|
478
|
+
post.picture.transform_url(crop: { dimensions: "300x500", coords: "50, 50", alignment: "center" })
|
433
479
|
# => "https://ucarecdn.com/ebbb9929-eb92-4f52-a212-eecfdb19d27d/-/crop/300x500/50,50/center/"
|
434
480
|
```
|
435
481
|
|
@@ -445,12 +491,13 @@ Uploadcare provides [APIs](https://uploadcare.com/docs/start/api/) to manage fil
|
|
445
491
|
|
446
492
|
#### Upload a single file
|
447
493
|
|
448
|
-
```
|
494
|
+
```ruby
|
449
495
|
# Load a file
|
450
|
-
|
496
|
+
file = File.open("kitten.png")
|
451
497
|
# => #<File:kitten.png>
|
498
|
+
|
452
499
|
# Upload file to Uploadcare
|
453
|
-
|
500
|
+
uploadcare_file = Uploadcare::UploadApi.upload_file(file)
|
454
501
|
# => {
|
455
502
|
# "uuid"=>"2d33999d-c74a-4ff9-99ea-abc23496b053",
|
456
503
|
# ...other file data...
|
@@ -459,10 +506,10 @@ $ uploadcare_file = Uploadcare::UploadApi.upload_file(file)
|
|
459
506
|
|
460
507
|
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).
|
461
508
|
|
462
|
-
```
|
509
|
+
```ruby
|
463
510
|
# Upload file from URL
|
464
|
-
|
465
|
-
|
511
|
+
url = "https://ucarecdn.com/80b807be-faad-4f01-bbbe-0bbde172b9de/1secVIDEO.mp4"
|
512
|
+
uploadcare_file = Uploadcare::UploadApi.upload_file(url)
|
466
513
|
# => [
|
467
514
|
# {
|
468
515
|
# "size"=>22108,
|
@@ -479,12 +526,12 @@ $ uploadcare_file = Uploadcare::UploadApi.upload_file(url)
|
|
479
526
|
|
480
527
|
#### Upload several files
|
481
528
|
|
482
|
-
```
|
529
|
+
```ruby
|
483
530
|
# Load a file
|
484
|
-
|
531
|
+
file = File.open("kitten.png")
|
485
532
|
# => #<File:kitten.png>
|
486
533
|
# Upload several files to Uploadcare
|
487
|
-
|
534
|
+
uploadcare_file = Uploadcare::UploadApi.upload_files([file])
|
488
535
|
# => [
|
489
536
|
# {
|
490
537
|
# "uuid"=>"2dfc94e6-e74e-4014-9ff5-a71b8928f4fa",
|
@@ -500,14 +547,14 @@ FileApi provides an interface to manage single files, stored on Uploadcare Serve
|
|
500
547
|
|
501
548
|
#### Get files
|
502
549
|
|
503
|
-
```
|
550
|
+
```ruby
|
504
551
|
# Valid options:
|
505
552
|
# removed: [true|false]
|
506
553
|
# stored: [true|false]
|
507
554
|
# limit: (1..1000)
|
508
555
|
# ordering: ["datetime_uploaded"|"-datetime_uploaded"]
|
509
556
|
# from: A starting point for filtering files. The value depends on your ordering parameter value.
|
510
|
-
|
557
|
+
Uploadcare::FileApi.get_files(ordering: "datetime_uploaded", limit: 10)
|
511
558
|
# => {
|
512
559
|
# "next"=>nil,
|
513
560
|
# "previous"=>nil,
|
@@ -525,7 +572,7 @@ $ Uploadcare::FileApi.get_files(ordering: "datetime_uploaded", limit: 10)
|
|
525
572
|
|
526
573
|
#### Get a file by UUID
|
527
574
|
|
528
|
-
```
|
575
|
+
```ruby
|
529
576
|
$ Uploadcare::FileApi.get_file("7b2b35b4-125b-4c1e-9305-12e8da8916eb")
|
530
577
|
# => {
|
531
578
|
# "cdn_url"=>"https://ucarecdn.com/7b2b35b4-125b-4c1e-9305-12e8da8916eb/",
|
@@ -536,10 +583,10 @@ $ Uploadcare::FileApi.get_file("7b2b35b4-125b-4c1e-9305-12e8da8916eb")
|
|
536
583
|
|
537
584
|
#### Copy a file to default storage. Source can be UID or full CDN link
|
538
585
|
|
539
|
-
```
|
586
|
+
```ruby
|
540
587
|
# Valid options:
|
541
588
|
# stored: [true|false]
|
542
|
-
|
589
|
+
Uploadcare::FileApi.local_copy_file("2d33999d-c74a-4ff9-99ea-abc23496b052", store: false)
|
543
590
|
# => {
|
544
591
|
# "uuid"=>"f486132c-2fa5-454e-9e70-93c5e01a7e04",
|
545
592
|
# ...other file data...
|
@@ -548,10 +595,10 @@ $ Uploadcare::FileApi.local_copy_file("2d33999d-c74a-4ff9-99ea-abc23496b052", st
|
|
548
595
|
|
549
596
|
#### Copy a file to custom storage. Source can be UID or full CDN link
|
550
597
|
|
551
|
-
```
|
598
|
+
```ruby
|
552
599
|
# Valid options:
|
553
600
|
# make_public: [true|false]
|
554
|
-
|
601
|
+
Uploadcare::FileApi.remote_copy_file("2d33999d-c74a-4ff9-99ea-abc23496b052", "mytarget", make_public: false)
|
555
602
|
# => {
|
556
603
|
# "uuid"=>"f486132c-2fa5-454e-9e70-93c5e01a7e04",
|
557
604
|
# ...other file data...
|
@@ -561,8 +608,8 @@ $ Uploadcare::FileApi.remote_copy_file("2d33999d-c74a-4ff9-99ea-abc23496b052", "
|
|
561
608
|
|
562
609
|
#### Store a file by UUID
|
563
610
|
|
564
|
-
```
|
565
|
-
|
611
|
+
```ruby
|
612
|
+
Uploadcare::FileApi.store_file("2d33999d-c74a-4ff9-99ea-abc23496b052")
|
566
613
|
# => {
|
567
614
|
# "uuid"=>"2d33999d-c74a-4ff9-99ea-abc23496b052",
|
568
615
|
# ...other file data...
|
@@ -572,8 +619,8 @@ $ Uploadcare::FileApi.store_file("2d33999d-c74a-4ff9-99ea-abc23496b052")
|
|
572
619
|
|
573
620
|
#### Store several files by UUIDs
|
574
621
|
|
575
|
-
```
|
576
|
-
|
622
|
+
```ruby
|
623
|
+
Uploadcare::FileApi.store_files(["f486132c-2fa5-454e-9e70-93c5e01a7e04"])
|
577
624
|
# => {
|
578
625
|
# "result" => [
|
579
626
|
# {
|
@@ -587,8 +634,8 @@ $ Uploadcare::FileApi.store_files(["f486132c-2fa5-454e-9e70-93c5e01a7e04"])
|
|
587
634
|
|
588
635
|
#### Delete a file by UUID
|
589
636
|
|
590
|
-
```
|
591
|
-
|
637
|
+
```ruby
|
638
|
+
Uploadcare::FileApi.delete_file("2d33999d-c74a-4ff9-99ea-abc23496b052")
|
592
639
|
# => {
|
593
640
|
# "uuid"=>"2d33999d-c74a-4ff9-99ea-abc23496b052",
|
594
641
|
# ...other file data...
|
@@ -598,8 +645,8 @@ $ Uploadcare::FileApi.delete_file("2d33999d-c74a-4ff9-99ea-abc23496b052")
|
|
598
645
|
|
599
646
|
#### Delete several files by UUIDs
|
600
647
|
|
601
|
-
```
|
602
|
-
|
648
|
+
```ruby
|
649
|
+
Uploadcare::FileApi.delete_files(["f486132c-2fa5-454e-9e70-93c5e01a7e04"])
|
603
650
|
# => {
|
604
651
|
# "result" => [
|
605
652
|
# {
|
@@ -617,13 +664,13 @@ GroupApi provides an interface to manage file groups stored on Uploadcare Server
|
|
617
664
|
|
618
665
|
#### Get file groups
|
619
666
|
|
620
|
-
```
|
667
|
+
```ruby
|
621
668
|
# Valid options:
|
622
669
|
# limit: (1..1000)
|
623
670
|
# ordering: ["datetime_created"|"-datetime_created"]
|
624
671
|
# from: A starting point for filtering group lists. MUST be a datetime value with T used as a separator.
|
625
672
|
# example: "2015-01-02T10:00:00"
|
626
|
-
|
673
|
+
Uploadcare::GroupApi.get_groups(ordering: "datetime_uploaded", limit: 10)
|
627
674
|
# => {
|
628
675
|
# "next"=>"next"=>"https://api.uploadcare.com/groups/?ordering=datetime_uploaded&limit=10&from=2021-07-16T11%3A12%3A12.236280%2B00%3A00&offset=0",
|
629
676
|
# "previous"=>nil,
|
@@ -646,8 +693,8 @@ $ Uploadcare::GroupApi.get_groups(ordering: "datetime_uploaded", limit: 10)
|
|
646
693
|
|
647
694
|
#### Get a single file group by a group ID
|
648
695
|
|
649
|
-
```
|
650
|
-
|
696
|
+
```ruby
|
697
|
+
Uploadcare::GroupApi.get_group("d476f4c9-44a9-4670-88a5-c3cf5d26a6c2~20")
|
651
698
|
# => {
|
652
699
|
# "cdn_url"=>"https://ucarecdn.com/d476f4c9-44a9-4670-88a5-c3cf5d26a6c2~20/",
|
653
700
|
# ...other group data...
|
@@ -661,8 +708,8 @@ $ Uploadcare::GroupApi.get_group("d476f4c9-44a9-4670-88a5-c3cf5d26a6c2~20")
|
|
661
708
|
|
662
709
|
#### Store files of a group by a group ID
|
663
710
|
|
664
|
-
```
|
665
|
-
|
711
|
+
```ruby
|
712
|
+
Uploadcare::GroupApi.store_group("d476f4c9-44a9-4670-88a5-c3cf5d26a6c2~20")
|
666
713
|
# => "200 OK"
|
667
714
|
```
|
668
715
|
|
@@ -675,8 +722,8 @@ It is possible to specify transformed URLs with UUIDs of files OR just UUIDs.
|
|
675
722
|
NOTE: Be sure to add a trailing slash "/" to the URL in case of specifying transformed URLs.
|
676
723
|
```
|
677
724
|
|
678
|
-
```
|
679
|
-
|
725
|
+
```ruby
|
726
|
+
Uploadcare::GroupApi.create_group(["e08dec9e-7e25-49c5-810e-4c360d86bbae/-/resize/300x500/"])
|
680
727
|
# => {
|
681
728
|
# "cdn_url"=>"https://ucarecdn.com/d476f4c9-44a9-4670-88a5-c3cf5d26a6c2~1/",
|
682
729
|
# ...other group data...
|
@@ -690,8 +737,8 @@ $ Uploadcare::GroupApi.create_group(["e08dec9e-7e25-49c5-810e-4c360d86bbae/-/res
|
|
690
737
|
|
691
738
|
#### Delete a file group by its ID
|
692
739
|
|
693
|
-
```
|
694
|
-
|
740
|
+
```ruby
|
741
|
+
Uploadcare::GroupApi.delete_group("90c93e96-965b-4dd2-b323-39d9bd5f492c~1")
|
695
742
|
# => "200 OK"
|
696
743
|
```
|
697
744
|
|
@@ -700,8 +747,8 @@ $ Uploadcare::GroupApi.delete_group("90c93e96-965b-4dd2-b323-39d9bd5f492c~1")
|
|
700
747
|
|
701
748
|
ProjectApi interface provides just one method - to get a configuration of your Uploadcare project.
|
702
749
|
|
703
|
-
```
|
704
|
-
|
750
|
+
```ruby
|
751
|
+
Uploadcare::ProjectApi.get_project
|
705
752
|
# => {
|
706
753
|
# "collaborators"=>[],
|
707
754
|
# "name"=>"New project",
|
@@ -719,8 +766,8 @@ WebhookApi allows to manage Uploadcare webhooks.
|
|
719
766
|
|
720
767
|
This method returns a non-paginated list of webhooks set in your project
|
721
768
|
|
722
|
-
```
|
723
|
-
|
769
|
+
```ruby
|
770
|
+
Uploadcare::WebhookApi.get_webhooks
|
724
771
|
# => [{
|
725
772
|
# "id"=>815677,
|
726
773
|
# "created"=>"2021-08-02T05:02:14.588794Z",
|
@@ -740,11 +787,11 @@ This method requires an URL that is triggered by an event, for example, a file u
|
|
740
787
|
Each webhook payload can be signed with a secret (the `signing_secret` option) to ensure that the request comes from the expected sender.
|
741
788
|
More info about secure webhooks [here](https://uploadcare.com/docs/security/secure-webhooks/).
|
742
789
|
|
743
|
-
```
|
790
|
+
```ruby
|
744
791
|
# Valid options:
|
745
792
|
# event: ["file.uploaded"]
|
746
793
|
# is_active: [true|false]
|
747
|
-
|
794
|
+
Uploadcare::WebhookApi.create_webhook("https://example.com", event: "file.uploaded", is_active: true, signing_secret: "some-secret")
|
748
795
|
# => {
|
749
796
|
# "id"=>815671,
|
750
797
|
# "created"=>"2021-08-02T05:02:14.588794Z",
|
@@ -761,11 +808,11 @@ $ Uploadcare::WebhookApi.create_webhook("https://example.com", event: "file.uplo
|
|
761
808
|
|
762
809
|
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.
|
763
810
|
|
764
|
-
```
|
811
|
+
```ruby
|
765
812
|
# Valid options:
|
766
813
|
# event: Presently, we only support the "file.uploaded" event
|
767
814
|
# is_active: [true|false]
|
768
|
-
|
815
|
+
Uploadcare::WebhookApi.update_webhook("webhook_id", target_url: "https://example1.com", event: "file.uploaded", is_active: false, signing_secret: "some-secret")
|
769
816
|
# => {
|
770
817
|
# "id"=>815671,
|
771
818
|
# "created"=>"2021-08-02T05:02:14.588794Z",
|
@@ -780,8 +827,8 @@ $ Uploadcare::WebhookApi.update_webhook("webhook_id", target_url: "https://examp
|
|
780
827
|
|
781
828
|
#### Delete an existing webhook by a target_url
|
782
829
|
|
783
|
-
```
|
784
|
-
|
830
|
+
```ruby
|
831
|
+
Uploadcare::WebhookApi.delete_webhook("https://example1.com")
|
785
832
|
# => Success(nil)
|
786
833
|
```
|
787
834
|
|
@@ -795,11 +842,11 @@ This method requires an UUID of a previously uploaded to Uploadcare file and tar
|
|
795
842
|
If using an image format, you can also specify a page number that must be converted for a document containing pages.
|
796
843
|
More info about document conversion can be found [here](https://uploadcare.com/docs/transformations/document-conversion/).
|
797
844
|
|
798
|
-
```
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
845
|
+
```ruby
|
846
|
+
Uploadcare::ConversionApi.convert_document(
|
847
|
+
{ uuid: "466740dd-cfad-4de4-9218-1ddc0edf7aa6", format: "png", page: 1 },
|
848
|
+
store: false
|
849
|
+
)
|
803
850
|
# => Success({
|
804
851
|
# :result=>[{
|
805
852
|
# :original_source=>"466740dd-cfad-4de4-9218-1ddc0edf7aa6/document/-/format/png/-/page/1/",
|
@@ -815,8 +862,8 @@ $ )
|
|
815
862
|
|
816
863
|
This method requires a token obtained in a response to the [convert_document](#convert-a-document) method.
|
817
864
|
|
818
|
-
```
|
819
|
-
|
865
|
+
```ruby
|
866
|
+
Uploadcare::ConversionApi.get_document_conversion_status(21316034)
|
820
867
|
# => Success({
|
821
868
|
# :result=>{
|
822
869
|
# :uuid=>"db6e52b8-cc03-4174-a07a-012be43b144e"
|
@@ -833,17 +880,17 @@ Such as the document conversion method, this method requires an UUID of a previo
|
|
833
880
|
Also you have several options to control the way a video will be converted. All of them are optional.
|
834
881
|
Description of valid options and other info about video conversion can be found [here](https://uploadcare.com/docs/transformations/video-encoding/).
|
835
882
|
|
836
|
-
```
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
883
|
+
```ruby
|
884
|
+
Uploadcare::ConversionApi.convert_video(
|
885
|
+
{
|
886
|
+
uuid: "466740dd-cfad-4de4-9218-1ddc0edf7aa6",
|
887
|
+
format: "ogg",
|
888
|
+
quality: "best",
|
889
|
+
cut: { start_time: "0:0:0.0", length: "0:0:1.0" },
|
890
|
+
thumbs: { N: 2, number: 1 }
|
891
|
+
},
|
892
|
+
store: false
|
893
|
+
)
|
847
894
|
# => Success({
|
848
895
|
# :result=>[{
|
849
896
|
# :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/",
|
@@ -860,8 +907,8 @@ $ )
|
|
860
907
|
|
861
908
|
This method requires a token obtained in a response to the [convert_video](#convert-a-video) method.
|
862
909
|
|
863
|
-
```
|
864
|
-
|
910
|
+
```ruby
|
911
|
+
Uploadcare::ConversionApi.get_video_conversion_status(916090555)
|
865
912
|
# => Success({
|
866
913
|
# :result=>{
|
867
914
|
# :uuid=>"f0a3e66e-cd22-4397-ba0a-8a8becc925f9",
|
@@ -881,15 +928,15 @@ Metadata is key-value data.
|
|
881
928
|
|
882
929
|
#### Get file's metadata keys and values
|
883
930
|
|
884
|
-
```
|
885
|
-
|
931
|
+
```ruby
|
932
|
+
Uploadcare::FileMetadataApi.file_metadata('f757ea10-8b1a-4361-9a7c-56bfa5d45176')
|
886
933
|
# => {:"sample-key"=>"sample-value"}
|
887
934
|
```
|
888
935
|
|
889
936
|
#### Get the value of a single metadata key
|
890
937
|
|
891
|
-
```
|
892
|
-
|
938
|
+
```ruby
|
939
|
+
Uploadcare::FileMetadataApi.file_metadata_value('f757ea10-8b1a-4361-9a7c-56bfa5d45176', 'sample-key')
|
893
940
|
# => "sample-value"
|
894
941
|
```
|
895
942
|
|
@@ -897,15 +944,15 @@ $ Uploadcare::FileMetadataApi.file_metadata_value('f757ea10-8b1a-4361-9a7c-56bfa
|
|
897
944
|
|
898
945
|
If the key does not exist, it will be created.
|
899
946
|
|
900
|
-
```
|
901
|
-
|
947
|
+
```ruby
|
948
|
+
Uploadcare::FileMetadataApi.update_file_metadata('f757ea10-8b1a-4361-9a7c-56bfa5d45176', 'sample-key', 'new-value')
|
902
949
|
# => "new-value"
|
903
950
|
```
|
904
951
|
|
905
952
|
#### Delete a file's metadata key
|
906
953
|
|
907
|
-
```
|
908
|
-
|
954
|
+
```ruby
|
955
|
+
Uploadcare::FileMetadataApi.delete_file_metadata('f757ea10-8b1a-4361-9a7c-56bfa5d45176', 'sample-key')
|
909
956
|
# => "200 OK"
|
910
957
|
```
|
911
958
|
|
@@ -920,52 +967,71 @@ An Add-On is an application implemented by Uploadcare that accepts uploaded file
|
|
920
967
|
Note: Detected labels are stored in the file's appdata.
|
921
968
|
```
|
922
969
|
|
923
|
-
```
|
924
|
-
|
970
|
+
```ruby
|
971
|
+
Uploadcare::AddonsApi.rekognition_detect_labels('f757ea10-8b1a-4361-9a7c-56bfa5d45176')
|
925
972
|
# => {"request_id"=>"dfeaf81c-5c0d-49d5-8ed4-ac09bac7998e"}
|
926
973
|
```
|
927
974
|
|
928
975
|
#### Check the status of an Add-On execution request that had been started using the Execute Add-On operation
|
929
976
|
|
930
|
-
```
|
931
|
-
|
977
|
+
```ruby
|
978
|
+
Uploadcare::AddonsApi.rekognition_detect_labels_status('dfeaf81c-5c0d-49d5-8ed4-ac09bac7998e')
|
932
979
|
# => {"status"=>"done"}
|
933
980
|
```
|
934
981
|
|
982
|
+
#### Execute AWS Rekognition Moderation Add-On for a given target to detect moderation labels in an image.
|
983
|
+
```
|
984
|
+
Note: Detected labels are stored in the file's appdata.
|
985
|
+
```
|
986
|
+
|
987
|
+
```ruby
|
988
|
+
Uploadcare::AddonsApi.rekognition_detect_moderation_labels('f757ea10-8b1a-4361-9a7c-56bfa5d45176')
|
989
|
+
# => {"request_id"=>"dfeaf81c-5c0d-49d5-8ed4-ac09bac7998e"}
|
990
|
+
```
|
991
|
+
|
992
|
+
# Check the status of an AWS Rekognition Moderation Add-On execution request that had been started using the Execute Add-On operation.
|
993
|
+
|
994
|
+
```ruby
|
995
|
+
Uploadcare::AddonsApi.rekognition_detect_moderation_labels_status('dfeaf81c-5c0d-49d5-8ed4-ac09bac7998e')
|
996
|
+
# => {"status"=>"done"}
|
997
|
+
```
|
998
|
+
|
999
|
+
|
1000
|
+
|
935
1001
|
#### Execute ClamAV virus checking Add-On for a given target
|
936
1002
|
|
937
|
-
```
|
938
|
-
|
1003
|
+
```ruby
|
1004
|
+
Uploadcare::AddonsApi.virus_scan('dfeaf81c-5c0d-49d5-8ed4-ac09bac7998e')
|
939
1005
|
# => {"request_id"=>"1b0126de-ace6-455b-82e2-25f4aa33fc6f"}
|
940
1006
|
```
|
941
1007
|
|
942
1008
|
#### Check the status of an Add-On execution request that had been started using the Execute Add-On operation
|
943
1009
|
|
944
|
-
```
|
945
|
-
|
1010
|
+
```ruby
|
1011
|
+
Uploadcare::AddonsApi.virus_scan_status('1b0126de-ace6-455b-82e2-25f4aa33fc6f')
|
946
1012
|
# => {"status"=>"done"}
|
947
1013
|
```
|
948
1014
|
|
949
1015
|
#### Execute remove.bg background image removal Add-On for a given target
|
950
1016
|
|
951
|
-
```
|
952
|
-
|
1017
|
+
```ruby
|
1018
|
+
Uploadcare::AddonsApi.remove_bg('f757ea10-8b1a-4361-9a7c-56bfa5d45176')
|
953
1019
|
# => {"request_id"=>"6d26a7d5-0955-4aeb-a9b1-c9776c83aa4c"}
|
954
1020
|
```
|
955
1021
|
|
956
1022
|
#### Check the status of an Add-On execution request that had been started using the Execute Add-On operation
|
957
1023
|
|
958
|
-
```
|
959
|
-
|
1024
|
+
```ruby
|
1025
|
+
Uploadcare::AddonsApi.remove_bg_status('6d26a7d5-0955-4aeb-a9b1-c9776c83aa4c')
|
960
1026
|
# => {"status"=>"done", "result"=>{"file_id"=>"8f0a2a28-3ed7-481e-b415-ee3cce982aaa"}}
|
961
1027
|
```
|
962
1028
|
|
963
1029
|
|
964
1030
|
## Useful links
|
965
|
-
* [Uploadcare documentation](https://uploadcare.com/docs/?utm_source=github&utm_medium=referral&utm_campaign=uploadcare-rails)
|
966
|
-
* [Upload API reference](https://uploadcare.com/api-refs/upload-api/?utm_source=github&utm_medium=referral&utm_campaign=uploadcare-rails)
|
967
|
-
* [REST API reference](https://uploadcare.com/api-refs/rest-api/?utm_source=github&utm_medium=referral&utm_campaign=uploadcare-rails)
|
968
|
-
* [Changelog](./CHANGELOG.md)
|
969
|
-
* [Contributing guide](https://github.com/uploadcare/.github/blob/master/CONTRIBUTING.md)
|
970
|
-
* [Security policy](https://github.com/uploadcare/uploadcare-rails/security/policy)
|
971
|
-
* [Support](https://github.com/uploadcare/.github/blob/master/SUPPORT.md)
|
1031
|
+
* [Uploadcare documentation](https://uploadcare.com/docs/?utm_source=github&utm_medium=referral&utm_campaign=uploadcare-rails)
|
1032
|
+
* [Upload API reference](https://uploadcare.com/api-refs/upload-api/?utm_source=github&utm_medium=referral&utm_campaign=uploadcare-rails)
|
1033
|
+
* [REST API reference](https://uploadcare.com/api-refs/rest-api/?utm_source=github&utm_medium=referral&utm_campaign=uploadcare-rails)
|
1034
|
+
* [Changelog](./CHANGELOG.md)
|
1035
|
+
* [Contributing guide](https://github.com/uploadcare/.github/blob/master/CONTRIBUTING.md)
|
1036
|
+
* [Security policy](https://github.com/uploadcare/uploadcare-rails/security/policy)
|
1037
|
+
* [Support](https://github.com/uploadcare/.github/blob/master/SUPPORT.md)
|
@@ -44,6 +44,18 @@ module Uploadcare
|
|
44
44
|
def remove_bg_status(uuid)
|
45
45
|
Uploadcare::Addons.remove_bg_status(uuid)
|
46
46
|
end
|
47
|
+
|
48
|
+
# Execute AWS Rekognition Moderation Add-On for a given target to detect labels in an image.
|
49
|
+
# @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/Add-Ons/operation/awsRekognitionDetectModerationLabelsExecute
|
50
|
+
def rekognition_detect_moderation_labels(uuid)
|
51
|
+
Uploadcare::Addons.ws_rekognition_detect_moderation_labels(uuid)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Check the status of an Add-On execution request that had been started using the Execute Add-On operation.
|
55
|
+
# @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/Add-Ons/operation/awsRekognitionDetectModerationLabelsExecutionStatus
|
56
|
+
def rekognition_detect_moderation_labels_status(uuid)
|
57
|
+
Uploadcare::Addons.ws_rekognition_detect_moderation_labels_status(uuid)
|
58
|
+
end
|
47
59
|
end
|
48
60
|
end
|
49
61
|
end
|
@@ -21,6 +21,12 @@ module Uploadcare
|
|
21
21
|
Uploadcare::VideoConverter.status(token)
|
22
22
|
end
|
23
23
|
|
24
|
+
# Conversion formats info
|
25
|
+
# @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/Conversion/operation/documentConvertInfo
|
26
|
+
def get_document_conversion_formats_info(uuid)
|
27
|
+
Uploadcare::DocumentConverter.info(uuid)
|
28
|
+
end
|
29
|
+
|
24
30
|
# Converts documents
|
25
31
|
# @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/documentConvert
|
26
32
|
def convert_document(document_params, options = {})
|
data/uploadcare-rails.gemspec
CHANGED
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.4.
|
4
|
+
version: 3.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "@dmitrijivanchenko (Dmitrij Ivanchenko), @T0mbery (Andrey Aksenov)"
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-06-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -31,14 +31,14 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
34
|
+
version: 4.4.2
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
41
|
+
version: 4.4.2
|
42
42
|
description: |
|
43
43
|
Rails API client (based on uploadcare-ruby) that handles uploads
|
44
44
|
and further operations with files by wrapping Uploadcare Upload and REST APIs.
|
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
118
|
- !ruby/object:Gem::Version
|
119
119
|
version: '0'
|
120
120
|
requirements: []
|
121
|
-
rubygems_version: 3.5.
|
121
|
+
rubygems_version: 3.5.4
|
122
122
|
signing_key:
|
123
123
|
specification_version: 4
|
124
124
|
summary: Rails gem for Uploadcare
|