uploadcare-ruby 3.3.2 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -8,15 +8,15 @@ module Uploadcare
8
8
  # This authentication method is more secure, but more tedious
9
9
  class SecureAuthHeader
10
10
  # @see https://uploadcare.com/docs/api_reference/rest/requests_auth/#auth-uploadcare
11
- def self.call(**options)
11
+ def self.call(options = {})
12
12
  @method = options[:method]
13
13
  @body = options[:content] || ''
14
14
  @content_type = options[:content_type]
15
15
  @uri = options[:uri]
16
16
  @date_for_header = timestamp
17
17
  {
18
- 'Date': @date_for_header,
19
- 'Authorization': "Uploadcare #{Uploadcare.config.public_key}:#{signature}"
18
+ Date: @date_for_header,
19
+ Authorization: "Uploadcare #{Uploadcare.config.public_key}:#{signature}"
20
20
  }
21
21
  end
22
22
 
@@ -7,7 +7,7 @@ module Uploadcare
7
7
  class SimpleAuthHeader
8
8
  # @see https://uploadcare.com/docs/api_reference/rest/requests_auth/#auth-simple
9
9
  def self.call
10
- { 'Authorization': "Uploadcare.Simple #{Uploadcare.config.public_key}:#{Uploadcare.config.secret_key}" }
10
+ { Authorization: "Uploadcare.Simple #{Uploadcare.config.public_key}:#{Uploadcare.config.secret_key}" }
11
11
  end
12
12
  end
13
13
  end
@@ -14,8 +14,8 @@ module Uploadcare
14
14
  to_sign = Uploadcare.config.secret_key + expires_at.to_s
15
15
  signature = Digest::MD5.hexdigest(to_sign)
16
16
  {
17
- 'signature': signature,
18
- 'expire': expires_at
17
+ signature: signature,
18
+ expire: expires_at
19
19
  }
20
20
  end
21
21
  end
@@ -8,14 +8,31 @@ module Uploadcare
8
8
  # This class generates body params for uploads
9
9
  class UploadParamsGenerator
10
10
  # @see https://uploadcare.com/docs/api_reference/upload/request_based/
11
- def self.call(store = 'auto')
12
- store = '1' if store == true
13
- store = '0' if store == false
14
- {
15
- 'UPLOADCARE_PUB_KEY' => Uploadcare.config.public_key,
16
- 'UPLOADCARE_STORE' => store,
17
- 'signature' => (Upload::SignatureGenerator.call if Uploadcare.config.sign_uploads)
18
- }.reject { |_k, v| v.nil? }
11
+ class << self
12
+ def call(options = {})
13
+ {
14
+ 'UPLOADCARE_PUB_KEY' => Uploadcare.config.public_key,
15
+ 'UPLOADCARE_STORE' => store(options[:store]),
16
+ 'signature' => (Upload::SignatureGenerator.call if Uploadcare.config.sign_uploads)
17
+ }.merge(metadata(options)).compact
18
+ end
19
+
20
+ private
21
+
22
+ def store(store)
23
+ store = 'auto' if store.nil?
24
+ store = '0' if store == false
25
+ store = '1' if store == true
26
+ store
27
+ end
28
+
29
+ def metadata(options = {})
30
+ return {} if options[:metadata].nil?
31
+
32
+ options[:metadata].each_with_object({}) do |(k, v), res|
33
+ res.merge!("metadata[#{k}]" => v)
34
+ end
35
+ end
19
36
  end
20
37
  end
21
38
  end
@@ -9,7 +9,7 @@ module Uploadcare
9
9
  # @see https://uploadcare.com/docs/security/secure-webhooks/
10
10
  def self.valid?(options = {})
11
11
  webhook_body_json = options[:webhook_body]
12
- signing_secret = options[:signing_secret] || ENV['UC_SIGNING_SECRET']
12
+ signing_secret = options[:signing_secret] || ENV.fetch('UC_SIGNING_SECRET', nil)
13
13
  x_uc_signature_header = options[:x_uc_signature_header]
14
14
 
15
15
  digest = OpenSSL::Digest.new('sha256')
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uploadcare
4
- VERSION = '3.3.2'
4
+ VERSION = '4.3.0'
5
5
  end
data/lib/uploadcare.rb CHANGED
@@ -59,4 +59,5 @@ module Uploadcare
59
59
  setting :max_throttle_attempts, default: 5
60
60
  setting :upload_threads, default: 2 # used for multiupload only ATM
61
61
  setting :framework_data, default: ''
62
+ setting :file_chunk_size, default: 100
62
63
  end
@@ -7,8 +7,7 @@ require 'uploadcare/ruby/version'
7
7
  Gem::Specification.new do |spec|
8
8
  spec.name = 'uploadcare-ruby'
9
9
  spec.version = Uploadcare::VERSION
10
- spec.authors = ['Stepan Redka']
11
- spec.email = ['stepan.redka@railsmuffin.com']
10
+ spec.authors = ['@dmitrijivanchenko (Dmitrij Ivanchenko), @T0mbery (Andrey Aksenov)']
12
11
 
13
12
  spec.summary = 'Ruby wrapper for uploadcare API'
14
13
  spec.description = spec.summary
@@ -23,9 +22,10 @@ Gem::Specification.new do |spec|
23
22
  spec.metadata['homepage_uri'] = spec.homepage
24
23
  spec.metadata['source_code_uri'] = 'https://github.com/uploadcare/uploadcare-ruby'
25
24
  spec.metadata['changelog_uri'] = 'https://github.com/uploadcare/uploadcare-ruby/CHANGELOG.md'
25
+ spec.metadata['rubygems_mfa_required'] = 'true'
26
26
  else
27
27
  raise 'RubyGems 2.0 or newer is required to protect against ' \
28
- 'public gem pushes.'
28
+ 'public gem pushes.'
29
29
  end
30
30
 
31
31
  # Specify which files should be added to the gem when it is released.
@@ -37,15 +37,15 @@ Gem::Specification.new do |spec|
37
37
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
38
38
  spec.require_paths = ['lib', 'lib/uploadcare', 'lib/uploadcare/rest']
39
39
 
40
- spec.add_dependency 'api_struct', '~> 1.0.1'
41
- spec.add_dependency 'dry-configurable', '~> 0.9'
42
- spec.add_dependency 'parallel'
43
- spec.add_dependency 'retries'
40
+ spec.add_dependency 'mimemagic', '~> 0.4'
41
+ spec.add_dependency 'parallel', '~> 1.22'
42
+ spec.add_dependency 'retries', '~> 0.0'
43
+ spec.add_dependency 'uploadcare-api_struct', '>= 1.1', '< 2'
44
44
 
45
- spec.add_development_dependency 'byebug'
45
+ spec.add_development_dependency 'byebug', '~> 11.1'
46
46
  spec.add_development_dependency 'rake', '~> 13.0'
47
47
  spec.add_development_dependency 'rspec', '~> 3.0'
48
- spec.add_development_dependency 'rubocop'
49
- spec.add_development_dependency 'vcr'
50
- spec.add_development_dependency 'webmock'
48
+ spec.add_development_dependency 'rubocop', '~> 1.48'
49
+ spec.add_development_dependency 'vcr', '~> 6.1'
50
+ spec.add_development_dependency 'webmock', '~> 3.18'
51
51
  end
metadata CHANGED
@@ -1,85 +1,91 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uploadcare-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.2
4
+ version: 4.3.0
5
5
  platform: ruby
6
6
  authors:
7
- - Stepan Redka
7
+ - "@dmitrijivanchenko (Dmitrij Ivanchenko), @T0mbery (Andrey Aksenov)"
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-18 00:00:00.000000000 Z
11
+ date: 2023-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: api_struct
14
+ name: mimemagic
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.1
19
+ version: '0.4'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.1
26
+ version: '0.4'
27
27
  - !ruby/object:Gem::Dependency
28
- name: dry-configurable
28
+ name: parallel
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.9'
33
+ version: '1.22'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.9'
40
+ version: '1.22'
41
41
  - !ruby/object:Gem::Dependency
42
- name: parallel
42
+ name: retries
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '0.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '0.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: retries
56
+ name: uploadcare-api_struct
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '1.1'
62
+ - - "<"
63
+ - !ruby/object:Gem::Version
64
+ version: '2'
62
65
  type: :runtime
63
66
  prerelease: false
64
67
  version_requirements: !ruby/object:Gem::Requirement
65
68
  requirements:
66
69
  - - ">="
67
70
  - !ruby/object:Gem::Version
68
- version: '0'
71
+ version: '1.1'
72
+ - - "<"
73
+ - !ruby/object:Gem::Version
74
+ version: '2'
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: byebug
71
77
  requirement: !ruby/object:Gem::Requirement
72
78
  requirements:
73
- - - ">="
79
+ - - "~>"
74
80
  - !ruby/object:Gem::Version
75
- version: '0'
81
+ version: '11.1'
76
82
  type: :development
77
83
  prerelease: false
78
84
  version_requirements: !ruby/object:Gem::Requirement
79
85
  requirements:
80
- - - ">="
86
+ - - "~>"
81
87
  - !ruby/object:Gem::Version
82
- version: '0'
88
+ version: '11.1'
83
89
  - !ruby/object:Gem::Dependency
84
90
  name: rake
85
91
  requirement: !ruby/object:Gem::Requirement
@@ -112,47 +118,46 @@ dependencies:
112
118
  name: rubocop
113
119
  requirement: !ruby/object:Gem::Requirement
114
120
  requirements:
115
- - - ">="
121
+ - - "~>"
116
122
  - !ruby/object:Gem::Version
117
- version: '0'
123
+ version: '1.48'
118
124
  type: :development
119
125
  prerelease: false
120
126
  version_requirements: !ruby/object:Gem::Requirement
121
127
  requirements:
122
- - - ">="
128
+ - - "~>"
123
129
  - !ruby/object:Gem::Version
124
- version: '0'
130
+ version: '1.48'
125
131
  - !ruby/object:Gem::Dependency
126
132
  name: vcr
127
133
  requirement: !ruby/object:Gem::Requirement
128
134
  requirements:
129
- - - ">="
135
+ - - "~>"
130
136
  - !ruby/object:Gem::Version
131
- version: '0'
137
+ version: '6.1'
132
138
  type: :development
133
139
  prerelease: false
134
140
  version_requirements: !ruby/object:Gem::Requirement
135
141
  requirements:
136
- - - ">="
142
+ - - "~>"
137
143
  - !ruby/object:Gem::Version
138
- version: '0'
144
+ version: '6.1'
139
145
  - !ruby/object:Gem::Dependency
140
146
  name: webmock
141
147
  requirement: !ruby/object:Gem::Requirement
142
148
  requirements:
143
- - - ">="
149
+ - - "~>"
144
150
  - !ruby/object:Gem::Version
145
- version: '0'
151
+ version: '3.18'
146
152
  type: :development
147
153
  prerelease: false
148
154
  version_requirements: !ruby/object:Gem::Requirement
149
155
  requirements:
150
- - - ">="
156
+ - - "~>"
151
157
  - !ruby/object:Gem::Version
152
- version: '0'
158
+ version: '3.18'
153
159
  description: Ruby wrapper for uploadcare API
154
- email:
155
- - stepan.redka@railsmuffin.com
160
+ email:
156
161
  executables: []
157
162
  extensions: []
158
163
  extra_rdoc_files: []
@@ -173,11 +178,13 @@ files:
173
178
  - bin/setup
174
179
  - lib/uploadcare.rb
175
180
  - lib/uploadcare/api/api.rb
181
+ - lib/uploadcare/client/addons_client.rb
176
182
  - lib/uploadcare/client/conversion/base_conversion_client.rb
177
183
  - lib/uploadcare/client/conversion/document_conversion_client.rb
178
184
  - lib/uploadcare/client/conversion/video_conversion_client.rb
179
185
  - lib/uploadcare/client/file_client.rb
180
186
  - lib/uploadcare/client/file_list_client.rb
187
+ - lib/uploadcare/client/file_metadata_client.rb
181
188
  - lib/uploadcare/client/group_client.rb
182
189
  - lib/uploadcare/client/multipart_upload/chunks_client.rb
183
190
  - lib/uploadcare/client/multipart_upload_client.rb
@@ -190,6 +197,7 @@ files:
190
197
  - lib/uploadcare/concern/error_handler.rb
191
198
  - lib/uploadcare/concern/throttle_handler.rb
192
199
  - lib/uploadcare/concern/upload_error_handler.rb
200
+ - lib/uploadcare/entity/addons.rb
193
201
  - lib/uploadcare/entity/conversion/base_converter.rb
194
202
  - lib/uploadcare/entity/conversion/document_converter.rb
195
203
  - lib/uploadcare/entity/conversion/video_converter.rb
@@ -197,6 +205,7 @@ files:
197
205
  - lib/uploadcare/entity/entity.rb
198
206
  - lib/uploadcare/entity/file.rb
199
207
  - lib/uploadcare/entity/file_list.rb
208
+ - lib/uploadcare/entity/file_metadata.rb
200
209
  - lib/uploadcare/entity/group.rb
201
210
  - lib/uploadcare/entity/group_list.rb
202
211
  - lib/uploadcare/entity/project.rb
@@ -227,6 +236,7 @@ metadata:
227
236
  homepage_uri: https://github.com/uploadcare/uploadcare-ruby
228
237
  source_code_uri: https://github.com/uploadcare/uploadcare-ruby
229
238
  changelog_uri: https://github.com/uploadcare/uploadcare-ruby/CHANGELOG.md
239
+ rubygems_mfa_required: 'true'
230
240
  post_install_message:
231
241
  rdoc_options: []
232
242
  require_paths:
@@ -244,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
244
254
  - !ruby/object:Gem::Version
245
255
  version: '0'
246
256
  requirements: []
247
- rubygems_version: 3.0.1
257
+ rubygems_version: 3.4.6
248
258
  signing_key:
249
259
  specification_version: 4
250
260
  summary: Ruby wrapper for uploadcare API