uploadcare-ruby 4.4.0 → 4.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 35dc34779d62684051b582e460d75f4e58acaa5f2c7372869b9fa753eea117e6
4
- data.tar.gz: ac06dcf3b4921a8199849111bbd38d1ae7cfad4ad1f5d0adb43a06c885102045
3
+ metadata.gz: 1cd6e50f0d12bc1cd65c531fa7e5656e41149433c042aedeb5d8899425ae6e53
4
+ data.tar.gz: baa9f7cc358eba65895e608073d2ad188bc68ff1b5a44b8c51e6d5b2e72fc8bb
5
5
  SHA512:
6
- metadata.gz: f189a6b962f27441c40f40f56db9fda78aa492e8d1ad1703663b85a6f6eb7df35f23fdab89c475ecbaec5701c0fc838d8d80f68ca7ee780c9037843906ade31c
7
- data.tar.gz: cf4a88871447ed9733cfc777486ee77d6113a55f523b3a6e6eac0ec9340f0652ec85c01434544352094f7672283879a130d6816df31c2a1ba5d8897176ed7dbb
6
+ metadata.gz: eab5bac3add563b090d18e7f82e2c7c852e95ff0d99530f8a3d25ec2d9eb47f1d146d38fc3dec9335af3bb9cebb74079b5fb27d3f46c7c1971d892185607df06
7
+ data.tar.gz: 2edc0a691512ac31210f5fada71d7515c59ac8305c5a522e04f2f90924af313cdba4707860e8bb6d1aaeec4053cff0869f0f5f14a458d33832c57587d3ab9822
data/.rubocop.yml CHANGED
@@ -4,6 +4,8 @@ AllCops:
4
4
 
5
5
  Layout/LineLength:
6
6
  Max: 120
7
+ Exclude:
8
+ - 'spec/**/*'
7
9
 
8
10
  Lint/IneffectiveAccessModifier:
9
11
  Enabled: false
@@ -20,6 +22,10 @@ Metrics/BlockLength:
20
22
  - 'spec/**/*'
21
23
  - 'uploadcare-ruby.gemspec'
22
24
 
25
+ Metrics/ModuleLength:
26
+ Exclude:
27
+ - 'spec/**/*'
28
+
23
29
  Metrics/MethodLength:
24
30
  Max: 20
25
31
 
data/CHANGELOG.md CHANGED
@@ -1,8 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.4.1 — 2024-04-27
4
+
5
+ ### Added
6
+ * Added `AWS Rekognition Moderation` Add-On.
7
+ * Added an optional `wildcard` boolean parameter to the `generate_url` method of `AkamaiGenerator`.
8
+
9
+ ### Changed
10
+ * File attribute `datetime_stored` is deprecated and will warn on usage from `File` object properties.
11
+
12
+ ### Fixed
13
+
14
+ * Throw `AuthError` if current public key or secret key config are empty when accessing any of the APIs.
15
+ * `AmakaiGenerator` has been renamed to `AkamaiGenerator` to fix typo in class name.
16
+
3
17
  ## 4.4.0 — 2024-03-09
4
18
 
5
- ### Breaking
19
+ ### Breaking
6
20
 
7
21
  * Drop support of unmaintainable Ruby versions < 3.x.
8
22
 
@@ -68,7 +82,7 @@ Add support of new ruby versions
68
82
  ### Breaking Сhanges
69
83
 
70
84
  - Drop support of unmaintainable Ruby versions (2.4, 2.5, 2.6).
71
- - Replace unmaintainable `api_struct` with `uploadcare-api_struct`
85
+ - Replace unmaintainable `api_struct` with `uploadcare-api_struct`
72
86
 
73
87
  ### Added
74
88
 
data/README.md CHANGED
@@ -95,7 +95,7 @@ Using Uploadcare is simple, and here are the basics of handling files.
95
95
  ```ruby
96
96
  @file_to_upload = File.open("your-file.png")
97
97
 
98
- @uc_file = Uploadcare::Uploader.upload(@file_to_upload)
98
+ @uc_file = Uploadcare::Uploader.upload(@file_to_upload, store: "auto")
99
99
 
100
100
  @uc_file.uuid
101
101
  # => "dc99200d-9bd6-4b43-bfa9-aa7bfaefca40"
@@ -105,13 +105,15 @@ Using Uploadcare is simple, and here are the basics of handling files.
105
105
  # => "https://ucarecdn.com/dc99200d-9bd6-4b43-bfa9-aa7bfaefca40/your-file.png"
106
106
  ```
107
107
 
108
- Your might then want to store or delete the uploaded file. Storing files could
109
- be crucial if you aren't using the “Automatic file storing” option for your
110
- Uploadcare project. If not stored manually or automatically, files get deleted
111
- within a 24-hour period.
108
+ The `store` option can have these possible values:
109
+ - `true`: mark the uploaded file as stored.
110
+ - `false`: do not mark the uploaded file as stored and remove it after 24 hours.
111
+ - `"auto"`: defers the choice of storage behavior to the [auto-store setting](https://app.uploadcare.com/projects/-/settings/#storage) for your Uploadcare project. This is the default behavior.
112
+
113
+ Your might then want to store or delete the uploaded file.
112
114
 
113
115
  ```ruby
114
- # that's how you store a file
116
+ # that's how you store a file, if you have uploaded the file using store: false and changed your mind later
115
117
  @uc_file.store
116
118
  # => #<Uploadcare::Api::File ...
117
119
 
@@ -128,16 +130,16 @@ Uploadcare supports multiple ways to upload files:
128
130
  # Smart upload - detects type of passed object and picks appropriate upload method
129
131
  # If you have a large file (more than 100Mb / 10485760 bytes), the uploader will automatically process it with a multipart upload
130
132
 
131
- Uploadcare::Uploader.upload("https://placekitten.com/96/139")
133
+ Uploadcare::Uploader.upload("https://placekitten.com/96/139", store: "auto")
132
134
  ```
133
135
 
134
136
  There are explicit ways to select upload type:
135
137
 
136
138
  ```ruby
137
139
  files = [File.open("1.jpg"), File.open("1.jpg")]
138
- Uploadcare::Uploader.upload_files(files)
140
+ Uploadcare::Uploader.upload_files(files, store: 'auto')
139
141
 
140
- Uploadcare::Uploader.upload_from_url("https://placekitten.com/96/139")
142
+ Uploadcare::Uploader.upload_from_url("https://placekitten.com/96/139", store: "auto")
141
143
  ```
142
144
  It is possible to track progress of the upload-from-URL process. To do that, you should specify the `async` option and get a token:
143
145
 
@@ -188,11 +190,12 @@ Options available in a block:
188
190
 
189
191
  #### Uploading options
190
192
 
191
- You can override global [`:autostore`](#initialization) option for each upload request:
193
+ You can override [auto-store setting](https://app.uploadcare.com/projects/-/settings/#storage) from your Uploadcare project for each upload request:
192
194
 
193
195
  ```ruby
194
- @api.upload(files, store: true)
195
- @api.upload_from_url(url, store: :auto)
196
+ @api.upload(files, store: true) # mark the uploaded file as stored.
197
+ @api.upload(files, store: false) # do not mark the uploaded file as stored and remove it after 24 hours.
198
+ @api.upload_from_url(url, store: "auto") # defers the choice of storage behavior to the auto-store setting.
196
199
  ```
197
200
 
198
201
  You can upload file with custom metadata, for example `subsystem` and `pet`:
@@ -208,10 +211,10 @@ Entities are representations of objects in Uploadcare cloud.
208
211
 
209
212
  #### File
210
213
 
211
- File entity contains its metadata. It also supports `include` param to include additional fields to the file object, such as: "appdata".
214
+ File entity contains its metadata. It also supports `include` param to include additional fields to the file object, such as: "appdata".
212
215
 
213
216
  ```ruby
214
- @file = Uploadcare::File.file("FILE_ID_IN_YOUR_PROJECT", include: "appdata")
217
+ @file = Uploadcare::File.file("FILE_UUID", include: "appdata")
215
218
  {
216
219
  "datetime_removed"=>nil,
217
220
  "datetime_stored"=>"2018-11-26T12:49:10.477888Z",
@@ -219,11 +222,11 @@ File entity contains its metadata. It also supports `include` param to include a
219
222
  "is_image"=>true,
220
223
  "is_ready"=>true,
221
224
  "mime_type"=>"image/jpeg",
222
- "original_file_url"=>"https://ucarecdn.com/FILE_ID_IN_YOUR_PROJECT/pineapple.jpg",
225
+ "original_file_url"=>"https://ucarecdn.com/FILE_UUID/pineapple.jpg",
223
226
  "original_filename"=>"pineapple.jpg",
224
227
  "size"=>642,
225
- "url"=>"https://api.uploadcare.com/files/FILE_ID_IN_YOUR_PROJECT/",
226
- "uuid"=>"FILE_ID_IN_YOUR_PROJECT",
228
+ "url"=>"https://api.uploadcare.com/files/FILE_UUID/",
229
+ "uuid"=>"FILE_UUID",
227
230
  "variations"=>nil,
228
231
  "content_info"=>{
229
232
  "mime"=>{
@@ -322,7 +325,7 @@ File entity contains its metadata. It also supports `include` param to include a
322
325
  The File object is also can be converted if it is a document or a video file. Imagine, you have a document file:
323
326
 
324
327
  ```ruby
325
- @file = Uploadcare::File.file("FILE_ID_IN_YOUR_PROJECT")
328
+ @file = Uploadcare::File.file("FILE_UUID")
326
329
  ```
327
330
 
328
331
  To convert it to an another file, just do:
@@ -437,16 +440,16 @@ As an example, you could store unique file identifier from your system.
437
440
 
438
441
  ```ruby
439
442
  # Get file's metadata keys and values.
440
- Uploadcare::FileMetadata.index('FILE_ID_IN_YOUR_PROJECT')
443
+ Uploadcare::FileMetadata.index('FILE_UUID')
441
444
 
442
445
  # Get the value of a single metadata key.
443
- Uploadcare::FileMetadata.show('FILE_ID_IN_YOUR_PROJECT', 'KEY')
446
+ Uploadcare::FileMetadata.show('FILE_UUID', 'KEY')
444
447
 
445
448
  # Update the value of a single metadata key. If the key does not exist, it will be created.
446
- Uploadcare::FileMetadata.update('FILE_ID_IN_YOUR_PROJECT', 'KEY', 'VALUE')
449
+ Uploadcare::FileMetadata.update('FILE_UUID', 'KEY', 'VALUE')
447
450
 
448
451
  # Delete a file's metadata key.
449
- Uploadcare::FileMetadata.delete('FILE_ID_IN_YOUR_PROJECT', 'KEY')
452
+ Uploadcare::FileMetadata.delete('FILE_UUID', 'KEY')
450
453
  ```
451
454
 
452
455
  #### Group
@@ -470,6 +473,7 @@ Uploadcare::Group.rest_info(group.id)
470
473
 
471
474
  # group can be deleted by group ID.
472
475
  Uploadcare::Group.delete(group.id)
476
+ # Note: This operation only removes the group object itself. All the files that were part of the group are left as is.
473
477
  ```
474
478
 
475
479
  #### GroupList
@@ -552,37 +556,50 @@ An `Add-On` is an application implemented by Uploadcare that accepts uploaded fi
552
556
  ##### AWS Rekognition
553
557
 
554
558
  ```ruby
555
- # 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.
556
- Uploadcare::Addons.ws_rekognition_detect_labels('FILE_ID_IN_YOUR_PROJECT')
559
+ # Execute AWS Rekognition Add-On for a given target to detect labels in an image.
560
+ # Note: Detected labels are stored in the file's appdata.
561
+ Uploadcare::Addons.ws_rekognition_detect_labels('FILE_UUID')
557
562
 
558
563
  # Check the status of AWS Rekognition.
559
564
  Uploadcare::Addons.ws_rekognition_detect_labels_status('RETURNED_ID_FROM_WS_REKOGNITION_DETECT_LABELS')
560
565
  ```
561
566
 
567
+ ##### AWS Rekognition Moderation
568
+
569
+ ```ruby
570
+ # Execute AWS Rekognition Moderation Add-On for a given target to detect moderation labels in an image.
571
+ # Note: Detected moderation labels are stored in the file's appdata.
572
+
573
+ Uploadcare::Addons.ws_rekognition_detect_moderation_labels('FILE_UUID')
574
+
575
+ # Check the status of an Add-On execution request that had been started using the Execute Add-On operation.
576
+ Uploadcare::Addons.ws_rekognition_detect_moderation_labels_status('RETURNED_ID_FROM_WS_REKOGNITION_DETECT_MODERATION_LABELS')
577
+ ```
578
+
562
579
  ##### ClamAV
563
580
 
564
581
  ```ruby
565
582
  # ClamAV virus checking Add-On for a given target.
566
- Uploadcare::Addons.uc_clamav_virus_scan('FILE_ID_IN_YOUR_PROJECT')
583
+ Uploadcare::Addons.uc_clamav_virus_scan('FILE_UUID')
567
584
 
568
- # Checking and purge infected file.
569
- Uploadcare::Addons.uc_clamav_virus_scan('FILE_ID_IN_YOUR_PROJECT', purge_infected: true )
585
+ # Check and purge infected file.
586
+ Uploadcare::Addons.uc_clamav_virus_scan('FILE_UUID', purge_infected: true )
570
587
 
571
- # Check the status ClamAV virus scan.
588
+ # Check the status of an Add-On execution request that had been started using the Execute Add-On operation.
572
589
  Uploadcare::Addons.uc_clamav_virus_scan_status('RETURNED_ID_FROM_UC_CLAMAV_VIRUS_SCAN')
573
590
  ```
574
591
 
575
592
  ##### Remove.bg
576
593
 
577
594
  ```ruby
578
- # Remove background image removal Add-On for a given target.
579
- Uploadcare::Addons.remove_bg('FILE_ID_IN_YOUR_PROJECT')
595
+ # Execute remove.bg background image removal Add-On for a given target.
596
+ Uploadcare::Addons.remove_bg('FILE_UUID')
580
597
 
581
598
  # You can pass optional parameters.
582
599
  # See the full list of parameters here: https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/removeBgExecute
583
- Uploadcare::Addons.remove_bg('FILE_ID_IN_YOUR_PROJECT', crop: true, type_level: '2')
600
+ Uploadcare::Addons.remove_bg('FILE_UUID', crop: true, type_level: '2')
584
601
 
585
- # Check the status of background image removal.
602
+ # Check the status of an Add-On execution request that had been started using the Execute Add-On operation.
586
603
  Uploadcare::Addons.remove_bg_status('RETURNED_ID_FROM_REMOVE_BG')
587
604
  ```
588
605
 
@@ -821,15 +838,29 @@ More examples and options can be found [here](https://uploadcare.com/docs/transf
821
838
 
822
839
  You can use custom domain and CDN provider to deliver files with authenticated URLs (see [original documentation](https://uploadcare.com/docs/security/secure_delivery/)).
823
840
 
824
- To generate authenticated URL from the library, you should choose `Uploadcare::SignedUrlGenerators::AmakaiGenerator` (or create your generator implementation):
841
+ To generate authenticated URL from the library, you should choose `Uploadcare::SignedUrlGenerators::AkamaiGenerator` (or create your own generator implementation):
842
+
825
843
  ```ruby
826
- generator = Uploadcare::SignedUrlGenerators::AmakaiGenerator.new(cdn_host: 'example.com', secret_key: 'secret_key'). Optional parameters: ttl: 300, algorithm: 'sha256'
844
+ generator = Uploadcare::SignedUrlGenerators::AkamaiGenerator.new(cdn_host: 'example.com', secret_key: 'secret_key')
845
+ # Optional parameters: ttl: 300, algorithm: 'sha256'
827
846
  generator.generate_url(uuid, acl = optional)
828
847
 
829
- generator.generate_url("a7d5645e-5cd7-4046-819f-a6a2933bafe3") ->
830
- https://example.com/a7d5645e-5cd7-4046-819f-a6a2933bafe3/?token=exp=1649405263~acl=/a7d5645e-5cd7-4046-819f-a6a2933bafe3/~hmac=a989cae5342f17013677f5a0e6577fc5594cc4e238fb4c95eda36634eb47018b
831
- generator.generate_url("a7d5645e-5cd7-4046-819f-a6a2933bafe3", '/*/') ->
832
- https://example.com/a7d5645e-5cd7-4046-819f-a6a2933bafe3/?token=exp=1649405263~acl=/*/~hmac=3ce1152c6af8864b36d4dc721f08ca3cf0b3a20278d7f849e82c6c930d48ccc1
848
+ generator.generate_url("a7d5645e-5cd7-4046-819f-a6a2933bafe3")
849
+ # https://example.com/a7d5645e-5cd7-4046-819f-a6a2933bafe3/?token=exp=1649405263~acl=/a7d5645e-5cd7-4046-819f-a6a2933bafe3/~hmac=a989cae5342f17013677f5a0e6577fc5594cc4e238fb4c95eda36634eb47018b
850
+
851
+ # You can pass in ACL as a second parameter to generate_url. See https://uploadcare.com/docs/security/secure-delivery/#authenticated-urls for supported acl formats
852
+ generator.generate_url("a7d5645e-5cd7-4046-819f-a6a2933bafe3", '/*/')
853
+ # https://example.com/a7d5645e-5cd7-4046-819f-a6a2933bafe3/?token=exp=1649405263~acl=/*/~hmac=3ce1152c6af8864b36d4dc721f08ca3cf0b3a20278d7f849e82c6c930d48ccc1
854
+
855
+ # Optionally you can use wildcard: true to generate a wildcard acl token
856
+ generator.generate_url("a7d5645e-5cd7-4046-819f-a6a2933bafe3", wildcard: true)
857
+ # https://example.com/a7d5645e-5cd7-4046-819f-a6a2933bafe3/?token=exp=1714233449~acl=/a7d5645e-5cd7-4046-819f-a6a2933bafe3/*~hmac=a568ee2a85dd90a8a8a1ef35ea0cc0ef0acb84fe81990edd3a06eacf10a52b4e
858
+
859
+ # You can also pass in a custom ttl and algorithm to AkamaiGenerator
860
+ generator = Uploadcare::SignedUrlGenerators::AkamaiGenerator.new(cdn_host: 'example.com', secret_key: 'secret_key', ttl: 10)
861
+ generator.generate_url("a7d5645e-5cd7-4046-819f-a6a2933bafe3")
862
+ # This generates a URL that expires in 10 seconds
863
+ # https://example.com/a7d5645e-5cd7-4046-819f-a6a2933bafe3/?token=exp=1714233277~acl=/a7d5645e-5cd7-4046-819f-a6a2933bafe3/~hmac=f25343104aeced3004d2cc4d49807d8d7c732300b54b154c319da5283a871a71
833
864
  ```
834
865
  ## Useful links
835
866
 
@@ -46,6 +46,19 @@ module Uploadcare
46
46
  get(uri: "/addons/remove_bg/execute/status/#{query_params(uuid)}")
47
47
  end
48
48
 
49
+ # Execute AWS Rekognition Moderation Add-On for a given target to detect labels in an image.
50
+ # @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/Add-Ons/operation/awsRekognitionDetectModerationLabelsExecute
51
+ def ws_rekognition_detect_moderation_labels(uuid)
52
+ content = { target: uuid }.to_json
53
+ post(uri: '/addons/aws_rekognition_detect_moderation_labels/execute/', content: content)
54
+ end
55
+
56
+ # Check the status of an Add-On execution request that had been started using the Execute Add-On operation.
57
+ # @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/Add-Ons/operation/awsRekognitionDetectModerationLabelsExecutionStatus
58
+ def ws_rekognition_detect_moderation_labels_status(uuid)
59
+ get(uri: "/addons/aws_rekognition_detect_moderation_labels/execute/status/#{query_params(uuid)}")
60
+ end
61
+
49
62
  private
50
63
 
51
64
  def query_params(uuid)
@@ -9,7 +9,7 @@ module Uploadcare
9
9
  class << self
10
10
  # Converts files
11
11
  #
12
- # @param doc_params [Array] of hashes with params or [Hash]
12
+ # @param params [Array] of hashes with params or [Hash]
13
13
  # @option options [Boolean] :store whether to store file on servers.
14
14
  def convert(params, options = {})
15
15
  files_params = params.is_a?(Hash) ? [params] : params
@@ -15,6 +15,11 @@ module Uploadcare
15
15
 
16
16
  attr_entity(*RESPONSE_PARAMS)
17
17
 
18
+ def datetime_stored
19
+ Uploadcare.config.logger&.warn 'datetime_stored property has been deprecated, and will be removed without a replacement in future.' # rubocop:disable Layout/LineLength
20
+ @entity.datetime_stored
21
+ end
22
+
18
23
  # gets file's uuid - even if it's only initialized with url
19
24
  # @returns [String]
20
25
  def uuid
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Uploadcare
4
+ module Exception
5
+ # Invalid Auth configuration error
6
+ class AuthError < StandardError; end
7
+ end
8
+ end
@@ -11,6 +11,7 @@ module Uploadcare
11
11
  class AuthenticationHeader
12
12
  # @see https://uploadcare.com/docs/api_reference/rest/requests_auth/#auth-uploadcare
13
13
  def self.call(options = {})
14
+ validate_auth_config
14
15
  case Uploadcare.config.auth_type
15
16
  when 'Uploadcare'
16
17
  SecureAuthHeader.call(options)
@@ -20,6 +21,17 @@ module Uploadcare
20
21
  raise ArgumentError, "Unknown auth_scheme: '#{Uploadcare.config.auth_type}'"
21
22
  end
22
23
  end
24
+
25
+ def self.validate_auth_config
26
+ raise AuthError, 'Public Key is blank.' if is_blank?(Uploadcare.config.public_key)
27
+ raise AuthError, 'Secret Key is blank.' if is_blank?(Uploadcare.config.secret_key)
28
+ end
29
+
30
+ # rubocop:disable Naming/PredicateName
31
+ def self.is_blank?(value)
32
+ value.nil? || value.empty?
33
+ end
34
+ # rubocop:enable Naming/PredicateName
23
35
  end
24
36
  end
25
37
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uploadcare
4
- VERSION = '4.4.0'
4
+ VERSION = '4.4.1'
5
5
  end
@@ -4,20 +4,21 @@ require_relative 'base_generator'
4
4
 
5
5
  module Uploadcare
6
6
  module SignedUrlGenerators
7
- class AmakaiGenerator < Uploadcare::SignedUrlGenerators::BaseGenerator
7
+ class AkamaiGenerator < Uploadcare::SignedUrlGenerators::BaseGenerator
8
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
9
  TEMPLATE = 'https://{cdn_host}/{uuid}/?token=exp={expiration}{delimiter}acl={acl}{delimiter}hmac={token}'
10
10
 
11
- def generate_url(uuid, acl = uuid)
11
+ def generate_url(uuid, acl = uuid, wildcard: false)
12
12
  raise ArgumentError, 'Must contain valid UUID' unless valid?(uuid)
13
13
 
14
+ formatted_acl = build_acl(uuid, acl, wildcard: wildcard)
14
15
  expire = build_expire
15
- signature = build_signature(expire, acl)
16
+ signature = build_signature(expire, formatted_acl)
16
17
 
17
18
  TEMPLATE.gsub('{delimiter}', delimiter)
18
19
  .sub('{cdn_host}', sanitized_string(cdn_host))
19
20
  .sub('{uuid}', sanitized_string(uuid))
20
- .sub('{acl}', "/#{sanitized_string(acl)}/")
21
+ .sub('{acl}', formatted_acl)
21
22
  .sub('{expiration}', expire)
22
23
  .sub('{token}', signature)
23
24
  end
@@ -32,13 +33,22 @@ module Uploadcare
32
33
  '~'
33
34
  end
34
35
 
36
+ def build_acl(uuid, acl, wildcard: false)
37
+ if wildcard
38
+ "/#{sanitized_string(uuid)}/*"
39
+ else
40
+ "/#{sanitized_string(acl)}/"
41
+ end
42
+ end
43
+
35
44
  def build_expire
36
45
  (Time.now.to_i + ttl).to_s
37
46
  end
38
47
 
39
48
  def build_signature(expire, acl)
40
- signature = ["exp=#{expire}", "acl=/#{sanitized_string(acl)}/"].join(delimiter)
41
- OpenSSL::HMAC.hexdigest(algorithm, secret_key, signature)
49
+ signature = ["exp=#{expire}", "acl=#{acl}"].join(delimiter)
50
+ secret_key_bin = Array(secret_key.gsub(/\s/, '')).pack('H*')
51
+ OpenSSL::HMAC.hexdigest(algorithm, secret_key_bin, signature)
42
52
  end
43
53
 
44
54
  # rubocop:disable Style/SlicingWithRange
data/lib/uploadcare.rb CHANGED
@@ -7,6 +7,7 @@ require 'ruby/version'
7
7
  require 'exception/throttle_error'
8
8
  require 'exception/request_error'
9
9
  require 'exception/retry_error'
10
+ require 'exception/auth_error'
10
11
 
11
12
  # Entities
12
13
  require 'entity/entity'
@@ -25,7 +26,7 @@ require 'param/webhook_signature_verifier'
25
26
  require 'api/api'
26
27
 
27
28
  # SignedUrlGenerators
28
- require 'signed_url_generators/amakai_generator'
29
+ require 'signed_url_generators/akamai_generator'
29
30
  require 'signed_url_generators/base_generator'
30
31
 
31
32
  # Ruby wrapper for Uploadcare API
@@ -49,4 +50,5 @@ module Uploadcare
49
50
  setting :upload_threads, default: 2 # used for multiupload only ATM
50
51
  setting :framework_data, default: ''
51
52
  setting :file_chunk_size, default: 100
53
+ setting :logger, default: Logger.new($stdout)
52
54
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uploadcare-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.0
4
+ version: 4.4.1
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: exe
11
11
  cert_chain: []
12
- date: 2024-03-09 00:00:00.000000000 Z
12
+ date: 2024-04-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mimemagic
@@ -130,6 +130,7 @@ files:
130
130
  - lib/uploadcare/entity/project.rb
131
131
  - lib/uploadcare/entity/uploader.rb
132
132
  - lib/uploadcare/entity/webhook.rb
133
+ - lib/uploadcare/exception/auth_error.rb
133
134
  - lib/uploadcare/exception/conversion_error.rb
134
135
  - lib/uploadcare/exception/request_error.rb
135
136
  - lib/uploadcare/exception/retry_error.rb
@@ -145,7 +146,7 @@ files:
145
146
  - lib/uploadcare/param/user_agent.rb
146
147
  - lib/uploadcare/param/webhook_signature_verifier.rb
147
148
  - lib/uploadcare/ruby/version.rb
148
- - lib/uploadcare/signed_url_generators/amakai_generator.rb
149
+ - lib/uploadcare/signed_url_generators/akamai_generator.rb
149
150
  - lib/uploadcare/signed_url_generators/base_generator.rb
150
151
  - uploadcare-ruby.gemspec
151
152
  homepage: https://uploadcare.com/
@@ -176,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
177
  - !ruby/object:Gem::Version
177
178
  version: '0'
178
179
  requirements: []
179
- rubygems_version: 3.5.3
180
+ rubygems_version: 3.5.9
180
181
  signing_key:
181
182
  specification_version: 4
182
183
  summary: Ruby wrapper for uploadcare API