cloudconvert 1.0.2 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -0
- data/cloudconvert.gemspec +3 -2
- data/lib/cloudconvert/client.rb +9 -4
- data/lib/cloudconvert/file.rb +1 -1
- data/lib/cloudconvert/resources/jobs.rb +1 -1
- data/lib/cloudconvert/resources/tasks.rb +1 -1
- data/lib/cloudconvert/signed_url.rb +24 -0
- data/lib/cloudconvert/version.rb +1 -1
- data/lib/cloudconvert/webhook/processor.rb +1 -1
- data/lib/cloudconvert.rb +5 -2
- metadata +30 -16
- data/lib/cloudconvert/middleware.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c673e3ee8e95029ba169554f076d54a63ccafeb2935708da8882babddba6f2dd
|
4
|
+
data.tar.gz: cae666dc7dda6a117cf0f81ba40086e35c135b63e478972aa082eabd631ae6c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d571515f826da72d7334981057c0d4cf987d5c34abf05353ad5479a3e10a3554f3ff76ea040f6841bda769400b076be9a1aed07435197d516e26aa0a0b226508
|
7
|
+
data.tar.gz: fb6262513b578d91d6c65a1ba8bbe40e149b051ba684458fb025e81e07fcdcea127cbe361aca89d8d78a80e344d5b40b55b8a92cb1342e3f5b50603255545b0b
|
data/README.md
CHANGED
@@ -207,6 +207,26 @@ The `verify`/`verify_request` methods return `true`/`false`, use `verify!` or `v
|
|
207
207
|
You can read the [full list of events](https://cloudconvert.com/api/v2/webhooks) CloudConvert can notify you about in our documentation.
|
208
208
|
|
209
209
|
|
210
|
+
Signed URL
|
211
|
+
--------
|
212
|
+
|
213
|
+
Signed URLs allow converting files on demand only using URL query parameters. The Ruby SDK allows to generate such URLs. Therefore, you need to obtain a signed URL base and a signing secret on the [CloudConvert Dashboard](https://cloudconvert.com/dashboard/api/v2/signed-urls).
|
214
|
+
|
215
|
+
```rb
|
216
|
+
base = 'https://s.cloudconvert.com/...' # You can find it in your signed URL settings.
|
217
|
+
signing_secret = '...' # You can find it in your signed URL settings.
|
218
|
+
cache_key = 'cache-key' # Allows caching of the result file for 24h
|
219
|
+
|
220
|
+
job = {
|
221
|
+
tasks: {
|
222
|
+
"import-it": { operation: "import/url", filename: "test.file", url: "http://invalid.url" },
|
223
|
+
"convert-it": { input: "import-it", operation: "convert", output_format: "pdf" },
|
224
|
+
}
|
225
|
+
}
|
226
|
+
|
227
|
+
url = CloudConvert::SignedUrl.sign(base, signing_secret, job, cache_key)
|
228
|
+
```
|
229
|
+
|
210
230
|
Development
|
211
231
|
-----------
|
212
232
|
|
data/cloudconvert.gemspec
CHANGED
@@ -20,8 +20,9 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.add_dependency "activesupport", ">= 4.0"
|
21
21
|
spec.add_dependency "down", "~> 5.0"
|
22
22
|
spec.add_dependency "equalizer"
|
23
|
-
spec.add_dependency "faraday", "
|
24
|
-
spec.add_dependency "
|
23
|
+
spec.add_dependency "faraday", ">= 2.0.1"
|
24
|
+
spec.add_dependency "faraday-multipart"
|
25
|
+
spec.add_dependency "faraday-follow_redirects"
|
25
26
|
spec.add_dependency "forwardable"
|
26
27
|
spec.add_dependency "json"
|
27
28
|
spec.add_dependency "memoizable", "~> 0.4"
|
data/lib/cloudconvert/client.rb
CHANGED
@@ -75,21 +75,26 @@ module CloudConvert
|
|
75
75
|
Down.download(url, *args, **options)
|
76
76
|
end
|
77
77
|
|
78
|
-
private
|
79
|
-
|
80
78
|
# @return [String]
|
81
79
|
def api_host
|
82
80
|
@api_host ||= sandbox ? SANDBOX_URL : API_URL
|
83
81
|
end
|
84
82
|
|
83
|
+
# @return [String]
|
84
|
+
def api_sync_host
|
85
|
+
@api_sync_host ||= sandbox ? SANDBOX_SYNC_URL : API_SYNC_URL
|
86
|
+
end
|
87
|
+
|
88
|
+
private
|
89
|
+
|
85
90
|
# @return [Faraday::Client]
|
86
91
|
def connection
|
87
92
|
@connection ||= Faraday.new(url: api_host, headers: headers) do |f|
|
88
93
|
f.adapter Faraday.default_adapter
|
89
94
|
f.request :json
|
90
95
|
f.request :multipart
|
91
|
-
f.
|
92
|
-
f.
|
96
|
+
f.response :json, content_type: /\bjson$/, parser_options: { object_class: OpenStruct }
|
97
|
+
f.response :follow_redirects, callback: lambda { |response, redirect|
|
93
98
|
redirect.request_headers.delete("Content-Length")
|
94
99
|
redirect.request_headers.delete("Content-Type")
|
95
100
|
}
|
data/lib/cloudconvert/file.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module CloudConvert
|
2
|
-
class File < Faraday::FilePart
|
2
|
+
class File < Faraday::Multipart::FilePart
|
3
3
|
def initialize(file, content_type = nil, *parts)
|
4
4
|
content_type ||= "text/plain" if file.is_a? StringIO
|
5
5
|
content_type ||= Marcel::Magic.by_magic(file) || Marcel::Magic.by_path(file)
|
@@ -51,7 +51,7 @@ module CloudConvert
|
|
51
51
|
# @param id [String]
|
52
52
|
# @return [Task]
|
53
53
|
def wait(id)
|
54
|
-
Task.result(client.get("/v2/tasks/#{id}
|
54
|
+
Task.result(client.get(client.api_sync_host + "/v2/tasks/#{id}"))
|
55
55
|
end
|
56
56
|
|
57
57
|
# @param file [File, String, IO] Either a String filename to a local file or an open IO object.
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module CloudConvert
|
2
|
+
class SignedUrl
|
3
|
+
class << self
|
4
|
+
# @param base [String] The base from for your signed URL settings.
|
5
|
+
# @param signing_secret [String] The signing secret from for your signed URL settings.
|
6
|
+
# @param job [Hash] The job to create the signed URL for
|
7
|
+
# @param cache_key [String] Allows caching of the result file for 24h
|
8
|
+
# @return [String] The signed URL
|
9
|
+
def sign(base, signing_secret, job, cache_key = nil)
|
10
|
+
url = base
|
11
|
+
|
12
|
+
url += "?job=" + Base64.urlsafe_encode64(job.to_json, padding: false)
|
13
|
+
|
14
|
+
unless cache_key.nil?
|
15
|
+
url += "&cache_key=" + cache_key
|
16
|
+
end
|
17
|
+
|
18
|
+
url += "&s=" + OpenSSL::HMAC.hexdigest("SHA256", signing_secret, url)
|
19
|
+
|
20
|
+
url
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/cloudconvert/version.rb
CHANGED
@@ -11,7 +11,7 @@ module CloudConvert::Webhook::Processor
|
|
11
11
|
|
12
12
|
def create
|
13
13
|
method = event.name.gsub(".", "_")
|
14
|
-
raise NoMethodError.new("#{name}##{method} not implemented") unless respond_to?(method, true)
|
14
|
+
raise NoMethodError.new("#{self.class.name}##{method} not implemented") unless respond_to?(method, true)
|
15
15
|
send(method, event)
|
16
16
|
head(:ok)
|
17
17
|
end
|
data/lib/cloudconvert.rb
CHANGED
@@ -3,7 +3,8 @@ require "active_support/core_ext/hash/reverse_merge"
|
|
3
3
|
require "down"
|
4
4
|
require "equalizer"
|
5
5
|
require "faraday"
|
6
|
-
require "
|
6
|
+
require "faraday/follow_redirects"
|
7
|
+
require "faraday/multipart"
|
7
8
|
require "forwardable"
|
8
9
|
require "json"
|
9
10
|
require "memoizable"
|
@@ -20,7 +21,6 @@ require "cloudconvert/error"
|
|
20
21
|
require "cloudconvert/event"
|
21
22
|
require "cloudconvert/file"
|
22
23
|
require "cloudconvert/job"
|
23
|
-
require "cloudconvert/middleware"
|
24
24
|
require "cloudconvert/resource"
|
25
25
|
require "cloudconvert/resources/jobs"
|
26
26
|
require "cloudconvert/resources/tasks"
|
@@ -30,9 +30,12 @@ require "cloudconvert/user"
|
|
30
30
|
require "cloudconvert/version"
|
31
31
|
require "cloudconvert/webhook"
|
32
32
|
require "cloudconvert/webhook/processor"
|
33
|
+
require "cloudconvert/signed_url"
|
33
34
|
|
34
35
|
module CloudConvert
|
35
36
|
API_URL = "https://api.cloudconvert.com".freeze
|
36
37
|
SANDBOX_URL = "https://api.sandbox.cloudconvert.com".freeze
|
38
|
+
API_SYNC_URL = "https://sync.api.cloudconvert.com".freeze
|
39
|
+
SANDBOX_SYNC_URL = "https://sync.api.sandbox.cloudconvert.com".freeze
|
37
40
|
USER_AGENT = "CloudConvertRubyGem/#{CloudConvert::VERSION}".freeze
|
38
41
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudconvert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josias Montag
|
8
8
|
- Steve Lacey
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-06-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -57,30 +57,44 @@ dependencies:
|
|
57
57
|
name: faraday
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- - "
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
62
|
+
version: 2.0.1
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- - "
|
67
|
+
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
69
|
+
version: 2.0.1
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
|
-
name:
|
71
|
+
name: faraday-multipart
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- - "
|
74
|
+
- - ">="
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: '
|
76
|
+
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- - "
|
81
|
+
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: '
|
83
|
+
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: faraday-follow_redirects
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
type: :runtime
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
84
98
|
- !ruby/object:Gem::Dependency
|
85
99
|
name: forwardable
|
86
100
|
requirement: !ruby/object:Gem::Requirement
|
@@ -353,11 +367,11 @@ files:
|
|
353
367
|
- lib/cloudconvert/event.rb
|
354
368
|
- lib/cloudconvert/file.rb
|
355
369
|
- lib/cloudconvert/job.rb
|
356
|
-
- lib/cloudconvert/middleware.rb
|
357
370
|
- lib/cloudconvert/resource.rb
|
358
371
|
- lib/cloudconvert/resources/jobs.rb
|
359
372
|
- lib/cloudconvert/resources/tasks.rb
|
360
373
|
- lib/cloudconvert/resources/users.rb
|
374
|
+
- lib/cloudconvert/signed_url.rb
|
361
375
|
- lib/cloudconvert/task.rb
|
362
376
|
- lib/cloudconvert/user.rb
|
363
377
|
- lib/cloudconvert/version.rb
|
@@ -370,7 +384,7 @@ metadata:
|
|
370
384
|
bug_tracker_uri: https://github.com/cloudconvert/cloudconvert-ruby/issues
|
371
385
|
documentation_uri: https://cloudconvert.com/api/v2
|
372
386
|
source_code_uri: https://github.com/cloudconvert/cloudconvert-ruby
|
373
|
-
post_install_message:
|
387
|
+
post_install_message:
|
374
388
|
rdoc_options: []
|
375
389
|
require_paths:
|
376
390
|
- lib
|
@@ -385,8 +399,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
385
399
|
- !ruby/object:Gem::Version
|
386
400
|
version: '0'
|
387
401
|
requirements: []
|
388
|
-
rubygems_version: 3.
|
389
|
-
signing_key:
|
402
|
+
rubygems_version: 3.0.3.1
|
403
|
+
signing_key:
|
390
404
|
specification_version: 4
|
391
405
|
summary: A Ruby interface to the CloudConvert API v2.
|
392
406
|
test_files: []
|