uploadcare-ruby 3.1.1 → 3.3.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 +4 -4
- data/CHANGELOG.md +30 -16
- data/README.md +84 -20
- data/lib/uploadcare/client/project_client.rb +2 -0
- data/lib/uploadcare/client/webhook_client.rb +3 -1
- data/lib/uploadcare/param/webhook_signature_verifier.rb +23 -0
- data/lib/uploadcare/ruby/version.rb +1 -1
- data/lib/uploadcare/signed_url_generators/amakai_generator.rb +53 -0
- data/lib/uploadcare/signed_url_generators/base_generator.rb +21 -0
- data/lib/uploadcare.rb +7 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b699a48dfd300be34dbfc459963a7d70aebd3a01e6b90204eb3a6deaa16d0da9
|
4
|
+
data.tar.gz: 3e0878f457950ec4c3a7da9b126691fbed2934b39aa43cb9d1983861377f7fd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79ff1377255bb94d221518a04f69fd83318c2ba9803fac49901220b0327820d75b12b7cb63a63c110a300635333c71432d7286899d437df25a080c575007ee92
|
7
|
+
data.tar.gz: a39a15cb2904b2a3f6b7c9a754242b66246f4059dc5deee47247c028fcf613b14ba00721722ca490304e635578422eb772e73c83b995ef939c661863dbd194cb
|
data/CHANGELOG.md
CHANGED
@@ -1,36 +1,50 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## 3.
|
3
|
+
## 3.3.1 - 2022-04-19
|
4
4
|
|
5
|
-
-
|
6
|
-
-
|
5
|
+
- Fixed README: `Uploadcare::URLGenerators::AmakaiGenerator` > `Uploadcare::SignedUrlGenerators::AmakaiGenerator`
|
6
|
+
- Autoload generators constants
|
7
7
|
|
8
|
-
## 3.
|
8
|
+
## 3.3.0 — 2022-04-08
|
9
9
|
|
10
|
-
- Added
|
11
|
-
- Added new attributes to the Entity class (variations, video_info, source, rekognition_info)
|
12
|
-
- Added an opportunity to add custom logic to large files uploading process
|
10
|
+
- Added `Uploadcare::URLGenerators::AmakaiGenerator`. Use custom domain and CDN provider to deliver files with authenticated URLs.
|
13
11
|
|
14
|
-
## 3.0
|
12
|
+
## 3.2.0 — 2021-11-16
|
13
|
+
|
14
|
+
- Added option `signing_secret` to the `Uploadcare::Webhook`
|
15
|
+
- Added webhook signature verifier class `Uploadcare::Param::WebhookSignatureVerifier`
|
16
|
+
|
17
|
+
## 3.1.1 — 2021-10-13
|
18
|
+
|
19
|
+
- Fixed `Uploadcare::File#store`
|
20
|
+
- Fixed `Uploadcare::File#delete`
|
21
|
+
|
22
|
+
## 3.1.0 — 2021-09-21
|
23
|
+
|
24
|
+
- Added documents and videos conversions
|
25
|
+
- Added new attributes to the Entity class (`variations`, `video_info`, `source`, `rekognition_info`)
|
26
|
+
- Added an option to add custom logic to large files uploading process
|
27
|
+
|
28
|
+
## 3.0.5 — 2021-04-15
|
15
29
|
|
16
30
|
- Replace Travis-CI with Github Actions
|
17
31
|
- Automate gem pushing
|
18
32
|
|
19
|
-
## 3.0.4-dev 2020-03-19
|
33
|
+
## 3.0.4-dev — 2020-03-19
|
20
34
|
|
21
|
-
- Added better pagination methods for GroupList & FileList
|
35
|
+
- Added better pagination methods for `GroupList` & `FileList`
|
22
36
|
- Improved documentation and install instructions
|
23
37
|
- Added CI
|
24
38
|
|
25
|
-
## 3.0.3-dev 2020-03-13
|
26
|
-
- Added better pagination and iterators for GroupList & FileList
|
39
|
+
## 3.0.3-dev — 2020-03-13
|
40
|
+
- Added better pagination and iterators for `GroupList` & `FileList`
|
27
41
|
|
28
|
-
## 3.0.2-dev 2020-03-11
|
42
|
+
## 3.0.2-dev — 2020-03-11
|
29
43
|
|
30
|
-
- Expanded File and Group entities
|
44
|
+
- Expanded `File` and `Group` entities
|
31
45
|
- Changed user agent syntax
|
32
46
|
|
33
|
-
## 3.0.1-dev 2020-03-11
|
47
|
+
## 3.0.1-dev — 2020-03-11
|
34
48
|
|
35
49
|
- Added Upload/group functionality
|
36
50
|
- Added user API
|
@@ -38,7 +52,7 @@
|
|
38
52
|
- Isolated clients, entities and concerns
|
39
53
|
- Expanded documentation
|
40
54
|
|
41
|
-
## 3.0.0-dev 2020-02-18
|
55
|
+
## 3.0.0-dev — 2020-02-18
|
42
56
|
|
43
57
|
### Changed
|
44
58
|
- Rewrote gem from scratch
|
data/README.md
CHANGED
@@ -52,7 +52,7 @@ And then execute:
|
|
52
52
|
|
53
53
|
$ bundle
|
54
54
|
|
55
|
-
If already not, create your project in [Uploadcare dashboard](https://uploadcare.com
|
55
|
+
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
56
|
its API keys from there.
|
57
57
|
|
58
58
|
Set your Uploadcare keys in config file or through environment variables:
|
@@ -75,7 +75,10 @@ Uploadcare.config.secret_key = "demoprivatekey"
|
|
75
75
|
|
76
76
|
This section contains practical usage examples. Please note, everything that
|
77
77
|
follows gets way more clear once you've looked through our
|
78
|
-
[docs](https://uploadcare.com/docs/?utm_source=github&utm_medium=referral&utm_campaign=uploadcare-ruby)
|
78
|
+
[docs](https://uploadcare.com/docs/?utm_source=github&utm_medium=referral&utm_campaign=uploadcare-ruby)
|
79
|
+
and [Upload](https://uploadcare.com/api-refs/upload-api/) and [REST](https://uploadcare.com/api-refs/rest-api/) API refs.
|
80
|
+
|
81
|
+
You can also find an example project [here](https://github.com/uploadcare/uploadcare-rails-example).
|
79
82
|
|
80
83
|
### Uploading files
|
81
84
|
#### Uploading and storing a single file
|
@@ -116,6 +119,8 @@ Uploadcare supports multiple ways to upload files:
|
|
116
119
|
|
117
120
|
```ruby
|
118
121
|
# Smart upload - detects type of passed object and picks appropriate upload method
|
122
|
+
# If you have a large file (more than 100Mb / 10485760 bytes), the uploader will automatically process it with a multipart upload
|
123
|
+
|
119
124
|
Uploadcare::Uploader.upload("https://placekitten.com/96/139")
|
120
125
|
```
|
121
126
|
|
@@ -295,8 +300,8 @@ how they should be fetched:
|
|
295
300
|
- **:limit** — Controls page size. Accepts values from 1 to 1000, defaults to 100.
|
296
301
|
- **:stored** — Can be either `true` or `false`. When true, file list will contain only stored files. When false — only not stored.
|
297
302
|
- **:removed** — Can be either `true` or `false`. When true, file list will contain only removed files. When false — all except removed. Defaults to false.
|
298
|
-
- **: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/
|
299
|
-
- **: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/
|
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).
|
300
305
|
|
301
306
|
Options used to create a file list can be accessed through `#options` method.
|
302
307
|
Note that, once set, they don't affect file fetching process anymore and are
|
@@ -369,18 +374,67 @@ https://uploadcare.com/docs/api_reference/rest/webhooks/
|
|
369
374
|
You can use webhooks to provide notifications about your uploads to target urls.
|
370
375
|
This gem lets you create and manage webhooks.
|
371
376
|
|
377
|
+
Each webhook payload can be signed with a secret (the `signing_secret` option) to ensure that the request comes from the expected sender.
|
378
|
+
More info about secure webhooks [here](https://uploadcare.com/docs/security/secure-webhooks/).
|
379
|
+
|
372
380
|
```ruby
|
373
|
-
Uploadcare::Webhook.create(target_url: "https://example.com/listen", event: "file.uploaded", is_active: true)
|
374
|
-
Uploadcare::Webhook.update(<webhook_id>, target_url: "https://newexample.com/listen/new", event: "file.uploaded", is_active: true)
|
381
|
+
Uploadcare::Webhook.create(target_url: "https://example.com/listen", event: "file.uploaded", is_active: true, signing_secret: "some-secret")
|
382
|
+
Uploadcare::Webhook.update(<webhook_id>, target_url: "https://newexample.com/listen/new", event: "file.uploaded", is_active: true, signing_secret: "some-secret")
|
375
383
|
Uploadcare::Webhook.delete("https://example.com/listen")
|
376
384
|
Uploadcare::Webhook.list
|
377
385
|
```
|
378
386
|
|
387
|
+
##### Webhook signature verification
|
388
|
+
|
389
|
+
The gem has a helper class to verify a webhook signature from headers —
|
390
|
+
`Uploadcare::Param::WebhookSignatureVerifier`. This class accepts three
|
391
|
+
important options:
|
392
|
+
|
393
|
+
- **:webhook_body** — this option represents parameters received in the webhook
|
394
|
+
request in the JSON format.
|
395
|
+
**NOTE**: if you're using Rails, you should exclude options `controller`,
|
396
|
+
`action` and `post` from the `webhook_body`.
|
397
|
+
- **:signing_secret** — the secret that was set while creating/updating a
|
398
|
+
webhook. This option can be specified as an ENV var with the name
|
399
|
+
`UC_SIGNING_SECRET` — then no need to send it to the verifier class.
|
400
|
+
- **:x_uc_signature_header** — the content of the `X-Uc-Signature` HTTP header
|
401
|
+
in the webhook request.
|
402
|
+
|
403
|
+
Using the `Uploadcare::Param::WebhookSignatureVerifier` class example:
|
404
|
+
|
405
|
+
```ruby
|
406
|
+
webhook_body = '{...}'
|
407
|
+
|
408
|
+
signing_secret = "12345X"
|
409
|
+
x_uc_signature_header = "v1=9b31c7dd83fdbf4a2e12b19d7f2b9d87d547672a325b9492457292db4f513c70"
|
410
|
+
|
411
|
+
Uploadcare::Param::WebhookSignatureVerifier.valid?(signing_secret: signing_secret, x_uc_signature_header: x_uc_signature_header, webhook_body: webhook_body)
|
412
|
+
```
|
413
|
+
|
414
|
+
You can write your verifier. Example code:
|
415
|
+
|
416
|
+
```ruby
|
417
|
+
webhook_body_json = '{...}'
|
418
|
+
|
419
|
+
signing_secret = ENV['UC_SIGNING_SECRET']
|
420
|
+
x_uc_signature_header = "v1=f4d859ed2fe47b9a4fcc81693d34e58ad12366a841e58a7072c1530483689cc0"
|
421
|
+
|
422
|
+
digest = OpenSSL::Digest.new('sha256')
|
423
|
+
|
424
|
+
calculated_signature = "v1=#{OpenSSL::HMAC.hexdigest(digest, signing_secret.force_encoding("utf-8"), webhook_body_json.force_encoding("utf-8"))}"
|
425
|
+
|
426
|
+
if calculated_signature == x_uc_signature_header
|
427
|
+
puts "WebHook signature matches!"
|
428
|
+
else
|
429
|
+
puts "WebHook signature mismatch!"
|
430
|
+
end
|
431
|
+
```
|
432
|
+
|
379
433
|
#### Project
|
380
434
|
|
381
435
|
`Project` provides basic info about the connected Uploadcare project. That
|
382
436
|
object is also an Hashie::Mash, so every methods out of
|
383
|
-
[these](https://uploadcare.com/
|
437
|
+
[these](https://uploadcare.com/api-refs/rest-api/v0.6.0/#operation/projectInfo) will work.
|
384
438
|
|
385
439
|
```ruby
|
386
440
|
@project = Uploadcare::Project.project
|
@@ -399,8 +453,6 @@ object is also an Hashie::Mash, so every methods out of
|
|
399
453
|
|
400
454
|
##### Video
|
401
455
|
|
402
|
-
Uploadcare can encode video files from all popular formats, adjust their quality, format and dimensions, cut out a video fragment, and generate thumbnails via [REST API](https://uploadcare.com/api-refs/rest-api/v0.6.0/).
|
403
|
-
|
404
456
|
After each video file upload you obtain a file identifier in UUID format.
|
405
457
|
Then you can use this file identifier to convert your video in multiple ways:
|
406
458
|
|
@@ -461,7 +513,7 @@ Params in the response:
|
|
461
513
|
- **original_source** - built path for a particular video with all the conversion operations and parameters.
|
462
514
|
- **token** - a processing job token that can be used to get a [job status](https://uploadcare.com/docs/transformations/video-encoding/#status) (see below).
|
463
515
|
- **uuid** - UUID of your processed video file.
|
464
|
-
- **thumbnails_group_uuid** - holds :uuid-thumb-group, a UUID of a [file group](https://uploadcare.com/api-refs/rest-api/v0.
|
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.
|
465
517
|
- **problems** - problems related to your processing job, if any.
|
466
518
|
|
467
519
|
To convert multiple videos just add params as a hash for each video to the first argument of the `Uploadcare::VideoConverter#convert` method:
|
@@ -508,12 +560,10 @@ Params in the response:
|
|
508
560
|
- **thumbnails_group_uuid** - holds :uuid-thumb-group, a UUID of a file group with thumbnails for an output video, based on the thumbs operation parameters.
|
509
561
|
- **uuid** - a UUID of your processed video file.
|
510
562
|
|
511
|
-
More examples and options can be found [here](https://uploadcare.com/docs/transformations/video-encoding/#video-encoding)
|
563
|
+
More examples and options can be found [here](https://uploadcare.com/docs/transformations/video-encoding/#video-encoding).
|
512
564
|
|
513
565
|
##### Document
|
514
566
|
|
515
|
-
Uploadcare allows converting documents to the following target formats: doc, docx, xls, xlsx, odt, ods, rtf, txt, pdf, jpg, png. Document Conversion works via our [REST API](https://uploadcare.com/api-refs/rest-api/v0.6.0/).
|
516
|
-
|
517
567
|
After each document file upload you obtain a file identifier in UUID format.
|
518
568
|
Then you can use this file identifier to convert your document to a new format:
|
519
569
|
|
@@ -611,13 +661,27 @@ Params in the response:
|
|
611
661
|
|
612
662
|
More examples and options can be found [here](https://uploadcare.com/docs/transformations/document-conversion/#document-conversion)
|
613
663
|
|
664
|
+
## Secure delivery
|
665
|
+
|
666
|
+
You can use custom domain and CDN provider to deliver files with authenticated URLs (see [original documentation](https://uploadcare.com/docs/security/secure_delivery/)).
|
667
|
+
|
668
|
+
To generate authenticated URL from the library, you should choose `Uploadcare::SignedUrlGenerators::AmakaiGenerator` (or create your generator implementation):
|
669
|
+
```ruby
|
670
|
+
generator = Uploadcare::SignedUrlGenerators::AmakaiGenerator.new(cdn_host: 'example.com', secret_key: 'secret_key'). Optional parameters: ttl: 300, algorithm: 'sha256'
|
671
|
+
generator.generate_url(uuid, acl = optional)
|
672
|
+
|
673
|
+
generator.generate_url("a7d5645e-5cd7-4046-819f-a6a2933bafe3") ->
|
674
|
+
https://example.com/a7d5645e-5cd7-4046-819f-a6a2933bafe3/?token=exp=1649405263~acl=/a7d5645e-5cd7-4046-819f-a6a2933bafe3/~hmac=a989cae5342f17013677f5a0e6577fc5594cc4e238fb4c95eda36634eb47018b
|
675
|
+
generator.generate_url("a7d5645e-5cd7-4046-819f-a6a2933bafe3", '/*/') ->
|
676
|
+
https://example.com/a7d5645e-5cd7-4046-819f-a6a2933bafe3/?token=exp=1649405263~acl=/*/~hmac=3ce1152c6af8864b36d4dc721f08ca3cf0b3a20278d7f849e82c6c930d48ccc1
|
677
|
+
```
|
614
678
|
## Useful links
|
615
679
|
|
616
680
|
* [Development](https://github.com/uploadcare/uploadcare-ruby/blob/main/DEVELOPMENT.md)
|
617
|
-
* [Uploadcare documentation](https://uploadcare.com/docs/?utm_source=github&utm_medium=referral&utm_campaign=uploadcare-ruby)
|
618
|
-
* [Upload API reference](https://uploadcare.com/api-refs/upload-api/?utm_source=github&utm_medium=referral&utm_campaign=uploadcare-ruby)
|
619
|
-
* [REST API reference](https://uploadcare.com/api-refs/rest-api/?utm_source=github&utm_medium=referral&utm_campaign=uploadcare-ruby)
|
620
|
-
* [Changelog](./CHANGELOG.md)
|
621
|
-
* [Contributing guide](https://github.com/uploadcare/.github/blob/master/CONTRIBUTING.md)
|
622
|
-
* [Security policy](https://github.com/uploadcare/uploadcare-ruby/security/policy)
|
623
|
-
* [Support](https://github.com/uploadcare/.github/blob/master/SUPPORT.md)
|
681
|
+
* [Uploadcare documentation](https://uploadcare.com/docs/?utm_source=github&utm_medium=referral&utm_campaign=uploadcare-ruby)
|
682
|
+
* [Upload API reference](https://uploadcare.com/api-refs/upload-api/?utm_source=github&utm_medium=referral&utm_campaign=uploadcare-ruby)
|
683
|
+
* [REST API reference](https://uploadcare.com/api-refs/rest-api/?utm_source=github&utm_medium=referral&utm_campaign=uploadcare-ruby)
|
684
|
+
* [Changelog](./CHANGELOG.md)
|
685
|
+
* [Contributing guide](https://github.com/uploadcare/.github/blob/master/CONTRIBUTING.md)
|
686
|
+
* [Security policy](https://github.com/uploadcare/uploadcare-ruby/security/policy)
|
687
|
+
* [Support](https://github.com/uploadcare/.github/blob/master/SUPPORT.md)
|
@@ -14,7 +14,9 @@ module Uploadcare
|
|
14
14
|
'target_url': options[:target_url],
|
15
15
|
'event': options[:event] || 'file.uploaded',
|
16
16
|
'is_active': options[:is_active].nil? ? true : options[:is_active]
|
17
|
-
}.
|
17
|
+
}.merge(
|
18
|
+
{ 'signing_secret': options[:signing_secret] }.compact
|
19
|
+
).to_json
|
18
20
|
post(uri: '/webhooks/', content: body)
|
19
21
|
end
|
20
22
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'digest/md5'
|
4
|
+
|
5
|
+
module Uploadcare
|
6
|
+
module Param
|
7
|
+
# This object verifies a signature received along with webhook headers
|
8
|
+
class WebhookSignatureVerifier
|
9
|
+
# @see https://uploadcare.com/docs/security/secure-webhooks/
|
10
|
+
def self.valid?(options = {})
|
11
|
+
webhook_body_json = options[:webhook_body]
|
12
|
+
signing_secret = options[:signing_secret] || ENV['UC_SIGNING_SECRET']
|
13
|
+
x_uc_signature_header = options[:x_uc_signature_header]
|
14
|
+
|
15
|
+
digest = OpenSSL::Digest.new('sha256')
|
16
|
+
|
17
|
+
calculated_signature = "v1=#{OpenSSL::HMAC.hexdigest(digest, signing_secret, webhook_body_json)}"
|
18
|
+
|
19
|
+
calculated_signature == x_uc_signature_header
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base_generator'
|
4
|
+
|
5
|
+
module Uploadcare
|
6
|
+
module SignedUrlGenerators
|
7
|
+
class AmakaiGenerator < Uploadcare::SignedUrlGenerators::BaseGenerator
|
8
|
+
UUID_REGEX = '[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}'
|
9
|
+
TEMPLATE = 'https://{cdn_host}/{uuid}/?token=exp={expiration}{delimiter}acl={acl}{delimiter}hmac={token}'
|
10
|
+
|
11
|
+
def generate_url(uuid, acl = uuid)
|
12
|
+
raise ArgumentError, 'Must contain valid UUID' unless valid?(uuid)
|
13
|
+
|
14
|
+
expire = build_expire
|
15
|
+
signature = build_signature(expire, acl)
|
16
|
+
|
17
|
+
TEMPLATE.gsub('{delimiter}', delimiter)
|
18
|
+
.sub('{cdn_host}', sanitized_string(cdn_host))
|
19
|
+
.sub('{uuid}', sanitized_string(uuid))
|
20
|
+
.sub('{acl}', "/#{sanitized_string(acl)}/")
|
21
|
+
.sub('{expiration}', expire)
|
22
|
+
.sub('{token}', signature)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def valid?(uuid)
|
28
|
+
uuid.match(UUID_REGEX)
|
29
|
+
end
|
30
|
+
|
31
|
+
def delimiter
|
32
|
+
'~'
|
33
|
+
end
|
34
|
+
|
35
|
+
def build_expire
|
36
|
+
(Time.now.to_i + ttl).to_s
|
37
|
+
end
|
38
|
+
|
39
|
+
def build_signature(expire, acl)
|
40
|
+
signature = ["exp=#{expire}", "acl=/#{sanitized_string(acl)}/"].join(delimiter)
|
41
|
+
OpenSSL::HMAC.hexdigest(algorithm, secret_key, signature)
|
42
|
+
end
|
43
|
+
|
44
|
+
# rubocop:disable Style/SlicingWithRange
|
45
|
+
def sanitized_string(string)
|
46
|
+
string = string[1..-1] if string[0] == '/'
|
47
|
+
string = string[0...-1] if string[-1] == '/'
|
48
|
+
string.strip
|
49
|
+
end
|
50
|
+
# rubocop:enable Style/SlicingWithRange
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Uploadcare
|
4
|
+
module SignedUrlGenerators
|
5
|
+
class BaseGenerator
|
6
|
+
attr_accessor :cdn_host, :ttl, :algorithm
|
7
|
+
attr_reader :secret_key
|
8
|
+
|
9
|
+
def initialize(cdn_host:, secret_key:, ttl: 300, algorithm: 'sha256')
|
10
|
+
@ttl = ttl
|
11
|
+
@algorithm = algorithm
|
12
|
+
@cdn_host = cdn_host
|
13
|
+
@secret_key = secret_key
|
14
|
+
end
|
15
|
+
|
16
|
+
def generate_url
|
17
|
+
raise NotImplementedError, "#{__method__} method not present"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/uploadcare.rb
CHANGED
@@ -17,9 +17,16 @@ require 'entity/project'
|
|
17
17
|
require 'entity/uploader'
|
18
18
|
require 'entity/webhook'
|
19
19
|
|
20
|
+
# Param
|
21
|
+
require 'param/webhook_signature_verifier'
|
22
|
+
|
20
23
|
# General api
|
21
24
|
require 'api/api'
|
22
25
|
|
26
|
+
# SignedUrlGenerators
|
27
|
+
require 'signed_url_generators/amakai_generator'
|
28
|
+
require 'signed_url_generators/base_generator'
|
29
|
+
|
23
30
|
# Ruby wrapper for Uploadcare API
|
24
31
|
#
|
25
32
|
# @see https://uploadcare.com/docs/api_reference
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uploadcare-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stepan Redka
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: api_struct
|
@@ -214,7 +214,10 @@ files:
|
|
214
214
|
- lib/uploadcare/param/upload/signature_generator.rb
|
215
215
|
- lib/uploadcare/param/upload/upload_params_generator.rb
|
216
216
|
- lib/uploadcare/param/user_agent.rb
|
217
|
+
- lib/uploadcare/param/webhook_signature_verifier.rb
|
217
218
|
- lib/uploadcare/ruby/version.rb
|
219
|
+
- lib/uploadcare/signed_url_generators/amakai_generator.rb
|
220
|
+
- lib/uploadcare/signed_url_generators/base_generator.rb
|
218
221
|
- uploadcare-ruby.gemspec
|
219
222
|
homepage: https://github.com/uploadcare/uploadcare-ruby
|
220
223
|
licenses:
|
@@ -241,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
241
244
|
- !ruby/object:Gem::Version
|
242
245
|
version: '0'
|
243
246
|
requirements: []
|
244
|
-
rubygems_version: 3.
|
247
|
+
rubygems_version: 3.0.1
|
245
248
|
signing_key:
|
246
249
|
specification_version: 4
|
247
250
|
summary: Ruby wrapper for uploadcare API
|