cloudconvert 1.0.0 → 1.1.0
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 +6 -1
- data/lib/cloudconvert/client.rb +7 -2
- 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.rb +4 -1
- metadata +14 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f05a16c577e0b30ddf30f9e73a087e1b79d40570f11b5a6013d98d9c372494c0
|
4
|
+
data.tar.gz: 7252a59fffb66d0797a04014251a3825a976a3470c8ca0d1adcd10865950512f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf3531174c00eb2b7ea64fac80e91a40a497ffdaed32f834fd9edb497b6fadf4514a6a6ada0e50fdd0e1d7e83f763d982408e4e883b9625bfcfcdda1bf2c3ead
|
7
|
+
data.tar.gz: a9a5b932ebf1eee1ada6a1d779bdf73ee6e1572fcaccfb2430496746d2ed8c83b8798e7e38fd61dea16b3a356d9391f05379a8d5137965d7281f5aed23690f3d
|
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
@@ -8,6 +8,11 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.description = "A Ruby interface to the CloudConvert API v2."
|
9
9
|
spec.summary = spec.description
|
10
10
|
spec.homepage = "https://cloudconvert.com/api/v2"
|
11
|
+
spec.metadata = {
|
12
|
+
"bug_tracker_uri" => "https://github.com/cloudconvert/cloudconvert-ruby/issues",
|
13
|
+
"documentation_uri" => "https://cloudconvert.com/api/v2",
|
14
|
+
"source_code_uri" => "https://github.com/cloudconvert/cloudconvert-ruby"
|
15
|
+
}
|
11
16
|
spec.files = %w[cloudconvert.gemspec LICENSE.txt README.md] + Dir["lib/**/*.rb"]
|
12
17
|
spec.license = "MIT"
|
13
18
|
spec.require_paths = %w[lib]
|
@@ -20,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
20
25
|
spec.add_dependency "forwardable"
|
21
26
|
spec.add_dependency "json"
|
22
27
|
spec.add_dependency "memoizable", "~> 0.4"
|
23
|
-
spec.add_dependency "
|
28
|
+
spec.add_dependency "marcel", "~> 1.0.0"
|
24
29
|
spec.add_dependency "openssl"
|
25
30
|
spec.add_dependency "ostruct"
|
26
31
|
spec.add_dependency "schemacop", "~> 2.4"
|
data/lib/cloudconvert/client.rb
CHANGED
@@ -75,13 +75,18 @@ 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|
|
data/lib/cloudconvert/file.rb
CHANGED
@@ -2,7 +2,7 @@ module CloudConvert
|
|
2
2
|
class File < Faraday::FilePart
|
3
3
|
def initialize(file, content_type = nil, *parts)
|
4
4
|
content_type ||= "text/plain" if file.is_a? StringIO
|
5
|
-
content_type ||=
|
5
|
+
content_type ||= Marcel::Magic.by_magic(file) || Marcel::Magic.by_path(file)
|
6
6
|
super(file, content_type, *parts)
|
7
7
|
end
|
8
8
|
end
|
@@ -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
data/lib/cloudconvert.rb
CHANGED
@@ -7,7 +7,7 @@ require "faraday_middleware"
|
|
7
7
|
require "forwardable"
|
8
8
|
require "json"
|
9
9
|
require "memoizable"
|
10
|
-
require "
|
10
|
+
require "marcel"
|
11
11
|
require "openssl"
|
12
12
|
require "ostruct"
|
13
13
|
require "schemacop"
|
@@ -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.0
|
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: 2022-03-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -124,19 +124,19 @@ dependencies:
|
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0.4'
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
|
-
name:
|
127
|
+
name: marcel
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
129
129
|
requirements:
|
130
130
|
- - "~>"
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version: 0.
|
132
|
+
version: 1.0.0
|
133
133
|
type: :runtime
|
134
134
|
prerelease: false
|
135
135
|
version_requirements: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
137
|
- - "~>"
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version: 0.
|
139
|
+
version: 1.0.0
|
140
140
|
- !ruby/object:Gem::Dependency
|
141
141
|
name: openssl
|
142
142
|
requirement: !ruby/object:Gem::Requirement
|
@@ -358,6 +358,7 @@ files:
|
|
358
358
|
- lib/cloudconvert/resources/jobs.rb
|
359
359
|
- lib/cloudconvert/resources/tasks.rb
|
360
360
|
- lib/cloudconvert/resources/users.rb
|
361
|
+
- lib/cloudconvert/signed_url.rb
|
361
362
|
- lib/cloudconvert/task.rb
|
362
363
|
- lib/cloudconvert/user.rb
|
363
364
|
- lib/cloudconvert/version.rb
|
@@ -366,8 +367,11 @@ files:
|
|
366
367
|
homepage: https://cloudconvert.com/api/v2
|
367
368
|
licenses:
|
368
369
|
- MIT
|
369
|
-
metadata:
|
370
|
-
|
370
|
+
metadata:
|
371
|
+
bug_tracker_uri: https://github.com/cloudconvert/cloudconvert-ruby/issues
|
372
|
+
documentation_uri: https://cloudconvert.com/api/v2
|
373
|
+
source_code_uri: https://github.com/cloudconvert/cloudconvert-ruby
|
374
|
+
post_install_message:
|
371
375
|
rdoc_options: []
|
372
376
|
require_paths:
|
373
377
|
- lib
|
@@ -382,8 +386,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
382
386
|
- !ruby/object:Gem::Version
|
383
387
|
version: '0'
|
384
388
|
requirements: []
|
385
|
-
rubygems_version: 3.1
|
386
|
-
signing_key:
|
389
|
+
rubygems_version: 3.0.3.1
|
390
|
+
signing_key:
|
387
391
|
specification_version: 4
|
388
392
|
summary: A Ruby interface to the CloudConvert API v2.
|
389
393
|
test_files: []
|