transloadit 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ci.yml +23 -0
- data/.standard.yml +0 -0
- data/CHANGELOG.md +70 -55
- data/Gemfile +1 -1
- data/README.md +162 -86
- data/Rakefile +12 -17
- data/examples/README.md +94 -55
- data/examples/basic/audio-concat-transcoder.rb +29 -19
- data/examples/basic/audio-transcoder.rb +32 -22
- data/examples/basic/image-transcoder.rb +22 -17
- data/examples/basic/main.rb +31 -37
- data/examples/basic/media-transcoder.rb +2 -7
- data/lib/transloadit/api_model.rb +13 -13
- data/lib/transloadit/assembly.rb +27 -24
- data/lib/transloadit/exception.rb +2 -4
- data/lib/transloadit/request.rb +58 -52
- data/lib/transloadit/response/assembly.rb +14 -13
- data/lib/transloadit/response.rb +10 -10
- data/lib/transloadit/step.rb +13 -13
- data/lib/transloadit/template.rb +5 -5
- data/lib/transloadit/version.rb +1 -1
- data/lib/transloadit.rb +24 -24
- data/test/fixtures/cassettes/cancel_assembly.yml +3 -3
- data/test/fixtures/cassettes/create_template.yml +1 -1
- data/test/fixtures/cassettes/delete_template.yml +1 -1
- data/test/fixtures/cassettes/fetch_assemblies.yml +1 -1
- data/test/fixtures/cassettes/fetch_assembly_aborted.yml +3 -3
- data/test/fixtures/cassettes/fetch_assembly_errors.yml +3 -3
- data/test/fixtures/cassettes/fetch_assembly_executing.yml +3 -3
- data/test/fixtures/cassettes/fetch_assembly_notifications.yml +1 -1
- data/test/fixtures/cassettes/fetch_assembly_ok.yml +6 -6
- data/test/fixtures/cassettes/fetch_assembly_uploading.yml +3 -3
- data/test/fixtures/cassettes/fetch_billing.yml +1 -1
- data/test/fixtures/cassettes/fetch_root.yml +3 -3
- data/test/fixtures/cassettes/fetch_template.yml +1 -1
- data/test/fixtures/cassettes/fetch_templates.yml +1 -1
- data/test/fixtures/cassettes/post_assembly.yml +2 -2
- data/test/fixtures/cassettes/rate_limit_fail.yml +3 -3
- data/test/fixtures/cassettes/rate_limit_succeed.yml +4 -4
- data/test/fixtures/cassettes/replay_assembly.yml +2 -2
- data/test/fixtures/cassettes/replay_assembly_notification.yml +1 -1
- data/test/fixtures/cassettes/submit_assembly.yml +3 -3
- data/test/fixtures/cassettes/update_template.yml +1 -1
- data/test/test_helper.rb +10 -10
- data/test/unit/test_transloadit.rb +66 -66
- data/test/unit/transloadit/test_api.rb +35 -33
- data/test/unit/transloadit/test_assembly.rb +148 -112
- data/test/unit/transloadit/test_request.rb +41 -42
- data/test/unit/transloadit/test_response.rb +76 -76
- data/test/unit/transloadit/test_step.rb +52 -52
- data/test/unit/transloadit/test_template.rb +49 -54
- data/transloadit.gemspec +25 -26
- metadata +25 -41
- data/.travis.yml +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c0001e9da3cd516d632f1f64b19e3c1a543b3fcb8b3d595ef357b1378be78575
|
4
|
+
data.tar.gz: c835af092c5046f590b6cd57570ee10b12aef5b8679da544f61217f5a349a8c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 179ec53008ed5bd7525a422bd3bdb6fe69ef4b665cb6fdfd1c6490ceb91ce9452c965ee5476a51494e144f1d8f02fda5344121763a0a0ea2bfaf0315b48633b4
|
7
|
+
data.tar.gz: 9b599ab52a8d44016cd4e9dcaf954fd845a4ae881f1c85b4efcb1d1a867e006eb433cd3b09333cbafa8f03f7ef8860ae3cd7668f72ce2415cb3cdb7256a1a3d8
|
@@ -0,0 +1,23 @@
|
|
1
|
+
name: CI
|
2
|
+
on: push
|
3
|
+
jobs:
|
4
|
+
ci:
|
5
|
+
runs-on: ubuntu-latest
|
6
|
+
strategy:
|
7
|
+
matrix:
|
8
|
+
ruby:
|
9
|
+
- 3.0
|
10
|
+
- 3.1
|
11
|
+
- 3.2
|
12
|
+
- jruby
|
13
|
+
# - jruby-head
|
14
|
+
- truffleruby
|
15
|
+
# - truffleruby-head
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v2
|
18
|
+
- uses: ruby/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: ${{ matrix.ruby }}
|
21
|
+
bundler-cache: true
|
22
|
+
- run: bundle exec standardrb
|
23
|
+
- run: COVERAGE=false bundle exec rake test
|
data/.standard.yml
ADDED
File without changes
|
data/CHANGELOG.md
CHANGED
@@ -1,85 +1,100 @@
|
|
1
|
-
###
|
1
|
+
### 3.0.0 / 2024-01-10
|
2
2
|
|
3
|
-
|
3
|
+
- BREAKING: Drop support for EOL'd Ruby 2.x
|
4
|
+
- Ensure that signature is sent before files [#65](https://github.com/transloadit/ruby-sdk/pull/65) (@Acconut)
|
5
|
+
- Send requests via HTTPS by default [#64](https://github.com/transloadit/ruby-sdk/pull/64) (@Acconut)
|
6
|
+
- Prevent duplicate assembly steps [#49](https://github.com/transloadit/ruby-sdk/issues/27) (@ifedapoolarewaju)
|
7
|
+
- Send "Transloadit-Client" header for every request (@ifedapoolarewaju)
|
8
|
+
- Send all requests via HTTPS by default
|
9
|
+
- Position signature before any files in requests [#51](https://github.com/transloadit/ruby-sdk/issues/51)
|
10
|
+
|
11
|
+
### 2.0.1 / 2017-01-23
|
12
|
+
|
13
|
+
- Use the ssl enabled url as the API base url (@ifedapoolarewaju)
|
14
|
+
|
15
|
+
### 2.0.0 / 2016-12-03
|
16
|
+
|
17
|
+
- Drop support for EOL'd Ruby 1.9.x and Ruby 2.0, please use version 1.2.0 if you need support for older
|
4
18
|
Ruby versions.
|
5
|
-
|
6
|
-
|
19
|
+
- Fix compatibility to Ruby >=2.1 and Rails 5.
|
20
|
+
- Remove bored instance logic (thanks @ifedapoolarewaju for the PR). This shouldn't affect users at all and removes
|
7
21
|
the need for another HTTP request before the actual HTTP request.
|
8
|
-
|
9
|
-
|
22
|
+
- We now have the `transloadit.bill` method to retrieve billing reports. (@ifedapoolarewaju)
|
23
|
+
- Deprecate `assembly.submit!` method for `assembly.create!`. This shouldn't affect users as the `submit!` method remains
|
10
24
|
as an alias for `create!`. (@ifedapoolarewaju)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
25
|
+
- Add support for new `assembly` methods (Thanks @ifedapoolarewaju):
|
26
|
+
- list to get a list of all assemblies.
|
27
|
+
- get to retrieve a particular assembly. Requires assembly id to be passed as argument.
|
28
|
+
- replay to replay a particular assembly. Requires assembly id to be passed as argument.
|
29
|
+
- get_notifications to get a list of all assembly notifications.
|
30
|
+
- replay_notification to replay the notification of a particular assembly. Requires assembly id to be passed as argument.
|
31
|
+
- We now have a Template api with the following methods:
|
32
|
+
- create to create a new template.
|
33
|
+
- list to get a list of all templates.
|
34
|
+
- get to retrieve a particular template.
|
35
|
+
- update to update a particular template.
|
36
|
+
- delete to delete a particular template.
|
37
|
+
- Add rate limit feature to implicitly retry assembly creation when the rate limit is reached.
|
38
|
+
- Add `assembly.reload_until_finished!` which calls `reload!` once per second until assembly is finished (@gbuesing)
|
39
|
+
- Added example files with a [small tutorial](examples/README.md) in `examples` (@jasonaibrahim)
|
26
40
|
|
27
|
-
### 1.2.0 / 2015-12-28
|
41
|
+
### 1.2.0 / 2015-12-28
|
28
42
|
|
29
|
-
|
43
|
+
- allow custom fields to be passed to Transloadit and received back in the response (thanks @Acconut for the pull request)
|
30
44
|
|
31
|
-
### 1.1.4 / 2015-12-14
|
45
|
+
### 1.1.4 / 2015-12-14
|
32
46
|
|
33
|
-
|
47
|
+
- fix Ruby 1.9.x compatibility by explicitly requiring mime-types 2.99
|
34
48
|
|
35
|
-
### 1.1.3 / 2014-08-21
|
49
|
+
### 1.1.3 / 2014-08-21
|
36
50
|
|
37
|
-
|
51
|
+
- Use rest-client < 1.7.0 for Ruby version below 1.9 to stay 1.8 compatible.
|
38
52
|
|
39
|
-
### 1.1.2 / 2014-06-17
|
53
|
+
### 1.1.2 / 2014-06-17
|
40
54
|
|
41
|
-
|
55
|
+
- Fix deprecation warning on Ruby 2.1.0 for OpenSSL::Digest (thanks @pekeler for the patch)
|
42
56
|
|
43
|
-
### 1.1.1 / 2013-06-25
|
57
|
+
### 1.1.1 / 2013-06-25
|
44
58
|
|
45
|
-
|
59
|
+
- request.get with secret (thanks @miry for the patch)
|
46
60
|
|
47
|
-
### 1.1.0 / 2013-04-22
|
61
|
+
### 1.1.0 / 2013-04-22
|
48
62
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
63
|
+
- We now have more statuses available in the response:
|
64
|
+
- finished? to check if processing is finished
|
65
|
+
- error? to check if processing failed with errors
|
66
|
+
- canceled? to check if processing was canceled
|
67
|
+
- aborted? to check if processing was aborted
|
68
|
+
- executing? to check if processing is still executing
|
69
|
+
- uploading? to check if the upload is still going
|
70
|
+
- Please use `finished?` to check if procssing is finished and `completed?` to
|
57
71
|
check if completed successfully
|
58
72
|
|
59
|
-
### 1.0.5 / 2013-03-13
|
73
|
+
### 1.0.5 / 2013-03-13
|
60
74
|
|
61
|
-
|
62
|
-
|
63
|
-
|
75
|
+
- Use MultiJSON so everyone can use the JSON parser they like. (thanks @kselden for the patch)
|
76
|
+
- Switch to Kramdown for RDoc formatting
|
77
|
+
- Support jRuby 1.8/1.9 and MRI 2.0.0 too
|
64
78
|
|
65
|
-
### 1.0.4 / 2013-03-06
|
79
|
+
### 1.0.4 / 2013-03-06
|
66
80
|
|
67
|
-
|
81
|
+
- allow symbols as keys for response attributes (thanks @gbuesing for reporting)
|
68
82
|
|
69
|
-
### 1.0.3 / 2012-11-10
|
83
|
+
### 1.0.3 / 2012-11-10
|
70
84
|
|
71
|
-
|
85
|
+
- Support max_size option
|
72
86
|
|
73
|
-
### 1.0.1 / 2011-02-08
|
87
|
+
### 1.0.1 / 2011-02-08
|
74
88
|
|
75
89
|
[Full list of changes](https://github.com/transloadit/ruby-sdk/compare/v1.0.0...v1.0.1)
|
76
90
|
|
77
|
-
|
78
|
-
|
91
|
+
- Enhancements
|
92
|
+
|
93
|
+
- support custom form fields for Transloadit::Assembly
|
79
94
|
|
80
|
-
|
81
|
-
|
95
|
+
- New Maintainers
|
96
|
+
- Robin Mehner <robin@coding-robin.de>
|
82
97
|
|
83
|
-
### 1.0.0 / 2011-09-06
|
98
|
+
### 1.0.0 / 2011-09-06
|
84
99
|
|
85
|
-
|
100
|
+
- Initial release
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,18 +1,17 @@
|
|
1
|
-
[![Build Status](https://
|
1
|
+
[![Build Status](https://github.com/transloadit/ruby-sdk/actions/workflows/ci.yml/badge.svg)](https://github.com/transloadit/ruby-sdk/actions/workflows/ci.yml)
|
2
2
|
[![Code Climate](https://codeclimate.com/github/transloadit/ruby-sdk.png)](https://codeclimate.com/github/transloadit/ruby-sdk)
|
3
|
-
[![Dependency Status](https://gemnasium.com/transloadit/ruby-sdk.png)](https://gemnasium.com/transloadit/ruby-sdk)
|
4
3
|
|
5
|
-
|
4
|
+
## ruby-sdk
|
6
5
|
|
7
|
-
|
6
|
+
A **Ruby** Integration for [Transloadit](https://transloadit.com)'s file uploading and encoding service
|
8
7
|
|
9
|
-
##
|
8
|
+
## Intro
|
10
9
|
|
11
|
-
|
12
|
-
you to automate uploading files through the Transloadit REST API.
|
10
|
+
[Transloadit](https://transloadit.com) is a service that helps you handle file uploads, resize, crop and watermark your images, make GIFs, transcode your videos, extract thumbnails, generate audio waveforms, and so much more. In short, [Transloadit](https://transloadit.com) is the Swiss Army Knife for your files.
|
13
11
|
|
14
|
-
|
15
|
-
|
12
|
+
This is a **Ruby** SDK to make it easy to talk to the [Transloadit](https://transloadit.com) REST API.
|
13
|
+
|
14
|
+
*If you run Ruby on Rails and are looking to integrate with the browser for file uploads, checkout the [rails-sdk](https://github.com/transloadit/rails-sdk).*
|
16
15
|
|
17
16
|
## Install
|
18
17
|
|
@@ -20,7 +19,7 @@ checkout the [rails-sdk](https://github.com/transloadit/rails-sdk).
|
|
20
19
|
gem install transloadit
|
21
20
|
```
|
22
21
|
|
23
|
-
##
|
22
|
+
## Usage
|
24
23
|
|
25
24
|
To get started, you need to require the 'transloadit' gem:
|
26
25
|
|
@@ -30,56 +29,64 @@ $ irb -rubygems
|
|
30
29
|
=> true
|
31
30
|
```
|
32
31
|
|
33
|
-
Then create a Transloadit instance, which will maintain your
|
34
|
-
credentials
|
32
|
+
Then create a Transloadit instance, which will maintain your
|
33
|
+
[authentication credentials](https://transloadit.com/accounts/credentials)
|
34
|
+
and allow us to make requests to [the API](https://transloadit.com/docs/api/).
|
35
35
|
|
36
36
|
```ruby
|
37
37
|
transloadit = Transloadit.new(
|
38
|
-
:key => '
|
39
|
-
:secret => '
|
38
|
+
:key => 'YOUR_TRANSLOADIT_KEY',
|
39
|
+
:secret => 'YOUR_TRANSLOADIT_SECRET'
|
40
40
|
)
|
41
41
|
```
|
42
42
|
|
43
43
|
### 1. Resize and store an image
|
44
44
|
|
45
|
-
This example demonstrates how you can create an
|
46
|
-
and store the result on [Amazon S3](
|
47
|
-
|
48
|
-
First, we create two steps: one to resize the image to 320x240, and another to
|
49
|
-
store the image in our S3 bucket.
|
45
|
+
This example demonstrates how you can create an <dfn>Assembly</dfn> to resize an image
|
46
|
+
and store the result on [Amazon S3](https://aws.amazon.com/s3/).
|
50
47
|
|
51
48
|
```ruby
|
49
|
+
require 'transloadit'
|
50
|
+
|
51
|
+
transloadit = Transloadit.new(
|
52
|
+
:key => 'YOUR_TRANSLOADIT_KEY',
|
53
|
+
:secret => 'YOUR_TRANSLOADIT_SECRET'
|
54
|
+
)
|
55
|
+
|
56
|
+
# First, we create two steps: one to resize the image to 320x240, and another to
|
57
|
+
# store the image in our S3 bucket.
|
52
58
|
resize = transloadit.step 'resize', '/image/resize',
|
53
59
|
:width => 320,
|
54
60
|
:height => 240
|
55
61
|
|
56
62
|
store = transloadit.step 'store', '/s3/store',
|
57
|
-
:key => '
|
58
|
-
:secret => '
|
59
|
-
:bucket => '
|
60
|
-
```
|
61
|
-
|
62
|
-
Now that we have the steps, we create an assembly (which is just a request to
|
63
|
-
process a file or set of files) and let Transloadit do the rest.
|
63
|
+
:key => 'YOUR_AWS_KEY',
|
64
|
+
:secret => 'YOUR_AWS_SECRET',
|
65
|
+
:bucket => 'YOUR_S3_BUCKET'
|
64
66
|
|
65
|
-
|
67
|
+
# Now that we have the steps, we create an assembly (which is just a request to
|
68
|
+
# process a file or set of files) and let Transloadit do the rest.
|
66
69
|
assembly = transloadit.assembly(
|
67
70
|
:steps => [ resize, store ]
|
68
71
|
)
|
69
72
|
|
70
|
-
response = assembly.create! open('
|
73
|
+
response = assembly.create! open('/PATH/TO/FILE.jpg')
|
71
74
|
|
72
75
|
# reloads the response once per second until all processing is finished
|
73
76
|
response.reload_until_finished!
|
74
77
|
|
75
78
|
if response.error?
|
76
|
-
|
79
|
+
# handle error
|
77
80
|
else
|
78
|
-
|
81
|
+
# handle other cases
|
82
|
+
puts response
|
79
83
|
end
|
80
84
|
```
|
81
|
-
|
82
|
-
|
85
|
+
|
86
|
+
<div class="alert alert-note">
|
87
|
+
<strong>Note:</strong> The <dfn>Assembly</dfn> method <code>submit!</code> has been deprecated and replaced with <code>create!</code>.
|
88
|
+
The <code>submit!</code> method remains as an alias of <code>create!</code> for backward Compatibility.
|
89
|
+
</div>
|
83
90
|
|
84
91
|
When the `create!` method returns, the file has been uploaded but may not yet
|
85
92
|
be done processing. We can use the returned object to check if processing has
|
@@ -90,7 +97,7 @@ completed, or examine other attributes of the request.
|
|
90
97
|
response[:assembly_id] # => '9bd733a...'
|
91
98
|
|
92
99
|
# returns the API URL endpoint for the assembly
|
93
|
-
response[:
|
100
|
+
response[:assembly_ssl_url] # => 'https://api2.vivian.transloadit.com/assemblies/9bd733a...'
|
94
101
|
|
95
102
|
# checks how many bytes were expected / received by transloadit
|
96
103
|
response[:bytes_expected] # => 92933
|
@@ -102,7 +109,7 @@ response.finished? # => false
|
|
102
109
|
# cancels further processing on the assembly
|
103
110
|
response.cancel! # => true
|
104
111
|
|
105
|
-
# checks if processing was
|
112
|
+
# checks if processing was successfully completed
|
106
113
|
response.completed? # => true
|
107
114
|
|
108
115
|
# checks if the processing returned with an error
|
@@ -111,21 +118,21 @@ response.error? # => false
|
|
111
118
|
|
112
119
|
It's important to note that none of these queries are "live" (with the
|
113
120
|
exception of the `cancel!` method). They all check the response given by the
|
114
|
-
API at the time the
|
115
|
-
|
121
|
+
API at the time the <dfn>Assembly</dfn> was created. You have to explicitly ask the
|
122
|
+
<dfn>Assembly</dfn> to reload its results from the API.
|
116
123
|
|
117
124
|
```ruby
|
118
125
|
# reloads the response's contents from the REST API
|
119
126
|
response.reload!
|
120
127
|
|
121
128
|
# reloads once per second until all processing is finished, up to number of
|
122
|
-
# times specified in :tries option,
|
129
|
+
# times specified in :tries option, otherwise will raise ReloadLimitReached
|
123
130
|
response.reload_until_finished! tries: 300 # default is 600
|
124
131
|
```
|
125
132
|
|
126
133
|
In general, you use hash accessor syntax to query any direct attribute from
|
127
|
-
the [response](
|
128
|
-
Methods suffixed by a question mark provide a more readable way of
|
134
|
+
the [response](https://transloadit.com/docs/api/#assembly-status-response).
|
135
|
+
Methods suffixed by a question mark provide a more readable way of querying
|
129
136
|
state (e.g., `assembly.completed?` vs. checking the result of
|
130
137
|
`assembly[:ok]`). Methods suffixed by a bang make a live query against the
|
131
138
|
Transloadit HTTP API.
|
@@ -133,10 +140,17 @@ Transloadit HTTP API.
|
|
133
140
|
### 2. Uploading multiple files
|
134
141
|
|
135
142
|
Multiple files can be given to the `create!` method in order to upload more
|
136
|
-
than one file in the same request. You can also pass a single
|
143
|
+
than one file in the same request. You can also pass a single <dfn>Step</dfn> for the
|
137
144
|
`steps` parameter, without having to wrap it in an Array.
|
138
145
|
|
139
146
|
```ruby
|
147
|
+
require 'transloadit'
|
148
|
+
|
149
|
+
transloadit = Transloadit.new(
|
150
|
+
:key => 'YOUR_TRANSLOADIT_KEY',
|
151
|
+
:secret => 'YOUR_TRANSLOADIT_SECRET'
|
152
|
+
)
|
153
|
+
|
140
154
|
assembly = transloadit.assembly(steps: store)
|
141
155
|
|
142
156
|
response = assembly.create!(
|
@@ -146,7 +160,9 @@ response = assembly.create!(
|
|
146
160
|
)
|
147
161
|
```
|
148
162
|
|
149
|
-
You can also pass an array of files to the `create!` method.
|
163
|
+
You can also pass an array of files to the `create!` method.
|
164
|
+
Just unpack the array using the splat `*` operator.
|
165
|
+
|
150
166
|
```ruby
|
151
167
|
files = [open('puppies.jpg'), open('kittens.jpg'), open('ferrets.jpg')]
|
152
168
|
response = assembly.create! *files
|
@@ -155,10 +171,17 @@ response = assembly.create! *files
|
|
155
171
|
### 3. Parallel Assembly
|
156
172
|
|
157
173
|
Transloadit allows you to perform several processing steps in parallel. You
|
158
|
-
simply need to `use` other
|
159
|
-
[their example](
|
174
|
+
simply need to `use` other <dfn>Steps</dfn>. Following
|
175
|
+
[their example](https://transloadit.com/docs/#special-parameters):
|
160
176
|
|
161
177
|
```ruby
|
178
|
+
require 'transloadit'
|
179
|
+
|
180
|
+
transloadit = Transloadit.new(
|
181
|
+
:key => 'YOUR_TRANSLOADIT_KEY',
|
182
|
+
:secret => 'YOUR_TRANSLOADIT_SECRET'
|
183
|
+
)
|
184
|
+
|
162
185
|
encode = transloadit.step 'encode', '/video/encode', { ... }
|
163
186
|
thumbs = transloadit.step 'thumbs', '/video/thumbs', { ... }
|
164
187
|
export = transloadit.step 'store', '/s3/store', { ... }
|
@@ -167,60 +190,91 @@ export.use [ encode, thumbs ]
|
|
167
190
|
|
168
191
|
transloadit.assembly(
|
169
192
|
:steps => [ encode, thumbs, export ]
|
170
|
-
).create! open('
|
193
|
+
).create! open('/PATH/TO/FILE.mpg')
|
171
194
|
```
|
172
195
|
|
173
196
|
You can also tell a step to use the original uploaded file by passing the
|
174
197
|
Symbol `:original` instead of another step.
|
175
198
|
|
176
199
|
Check the YARD documentation for more information on using
|
177
|
-
[use](
|
200
|
+
[use](https://rubydoc.info/gems/transloadit/frames/Transloadit/Step#use-instance_method).
|
178
201
|
|
179
202
|
### 4. Creating an Assembly with Templates
|
180
203
|
|
181
|
-
Transloadit allows you to use custom [templates](https://github.com/transloadit/ruby-sdk/blob/
|
204
|
+
Transloadit allows you to use custom [templates](https://github.com/transloadit/ruby-sdk/blob/main/README.md#8-templates)
|
182
205
|
for recurring encoding tasks. In order to use these do the following:
|
183
206
|
|
184
207
|
```ruby
|
208
|
+
require 'transloadit'
|
209
|
+
|
210
|
+
transloadit = Transloadit.new(
|
211
|
+
:key => 'YOUR_TRANSLOADIT_KEY',
|
212
|
+
:secret => 'YOUR_TRANSLOADIT_SECRET'
|
213
|
+
)
|
214
|
+
|
185
215
|
transloadit.assembly(
|
186
216
|
:template_id => 'YOUR_TEMPLATE_ID'
|
187
|
-
).create! open('
|
217
|
+
).create! open('/PATH/TO/FILE.mpg')
|
188
218
|
```
|
189
219
|
|
190
220
|
You can use your steps together with this template and even use variables.
|
191
|
-
The [Transloadit documentation](
|
192
|
-
examples for that.
|
221
|
+
The [Transloadit documentation](https://transloadit.com/docs/#passing-variables-into-a-template)
|
222
|
+
has some nice examples for that.
|
193
223
|
|
194
224
|
### 5. Using fields
|
195
225
|
|
196
226
|
Transloadit allows you to submit form field values that you'll get back in the
|
197
|
-
notification. This is quite handy if you want to add additional custom
|
227
|
+
notification. This is quite handy if you want to add additional custom metadata
|
198
228
|
to the upload itself. You can use fields like the following:
|
199
229
|
|
200
230
|
```ruby
|
231
|
+
require 'transloadit'
|
232
|
+
|
233
|
+
transloadit = Transloadit.new(
|
234
|
+
:key => 'YOUR_TRANSLOADIT_KEY',
|
235
|
+
:secret => 'YOUR_TRANSLOADIT_SECRET'
|
236
|
+
)
|
237
|
+
|
201
238
|
transloadit.assembly(
|
202
|
-
:fields => {
|
203
|
-
|
239
|
+
:fields => {
|
240
|
+
:tag => 'some_tag_name',
|
241
|
+
:field_name => 'field_value'
|
242
|
+
}
|
243
|
+
).create! open('/PATH/TO/FILE.mpg')
|
204
244
|
```
|
205
245
|
|
206
246
|
### 6. Notify URL
|
207
247
|
|
208
248
|
If you want to be notified when the processing is finished you can provide
|
209
|
-
a
|
249
|
+
a Notify URL for the <dfn>Assembly</dfn>.
|
210
250
|
|
211
251
|
```ruby
|
252
|
+
require 'transloadit'
|
253
|
+
|
254
|
+
transloadit = Transloadit.new(
|
255
|
+
:key => 'YOUR_TRANSLOADIT_KEY',
|
256
|
+
:secret => 'YOUR_TRANSLOADIT_SECRET'
|
257
|
+
)
|
258
|
+
|
212
259
|
transloadit.assembly(
|
213
|
-
:notify_url => '
|
214
|
-
).create! open('
|
260
|
+
:notify_url => 'https://example.com/processing_finished'
|
261
|
+
).create! open('/PATH/TO/FILE.mpg')
|
215
262
|
```
|
216
263
|
|
217
|
-
Read up more on the
|
264
|
+
Read up more on the <dfn>Notifications</dfn> [on Transloadit's documentation page](https://transloadit.com/docs/#notifications)
|
218
265
|
|
219
266
|
### 7. Other Assembly methods
|
220
267
|
|
221
|
-
Transloadit also provides methods to retrieve/replay
|
268
|
+
Transloadit also provides methods to retrieve/replay <dfn>Assemblies</dfn> and their <dfn>Notifications</dfn>.
|
222
269
|
|
223
270
|
```ruby
|
271
|
+
require 'transloadit'
|
272
|
+
|
273
|
+
transloadit = Transloadit.new(
|
274
|
+
:key => 'YOUR_TRANSLOADIT_KEY',
|
275
|
+
:secret => 'YOUR_TRANSLOADIT_SECRET'
|
276
|
+
)
|
277
|
+
|
224
278
|
assembly = transloadit.assembly
|
225
279
|
|
226
280
|
# returns a list of all assemblies
|
@@ -243,10 +297,17 @@ assembly.replay_notification 'YOUR_ASSEMBLY_ID'
|
|
243
297
|
|
244
298
|
### 8. Templates
|
245
299
|
|
246
|
-
Transloadit provides a [templates api](https://transloadit.com/docs
|
247
|
-
for recurring encoding tasks. Here's how you would create a
|
300
|
+
Transloadit provides a [templates api](https://transloadit.com/docs/#templates)
|
301
|
+
for recurring encoding tasks. Here's how you would create a <dfn>Template</dfn>:
|
248
302
|
|
249
303
|
```ruby
|
304
|
+
require 'transloadit'
|
305
|
+
|
306
|
+
transloadit = Transloadit.new(
|
307
|
+
:key => 'YOUR_TRANSLOADIT_KEY',
|
308
|
+
:secret => 'YOUR_TRANSLOADIT_SECRET'
|
309
|
+
)
|
310
|
+
|
250
311
|
template = transloadit.template
|
251
312
|
|
252
313
|
# creates a new template
|
@@ -264,9 +325,18 @@ template.create(
|
|
264
325
|
)
|
265
326
|
```
|
266
327
|
|
267
|
-
There are also some other methods to retrieve, update and delete a
|
328
|
+
There are also some other methods to retrieve, update and delete a <dfn>Template</dfn>.
|
268
329
|
|
269
330
|
```ruby
|
331
|
+
require 'transloadit'
|
332
|
+
|
333
|
+
transloadit = Transloadit.new(
|
334
|
+
:key => 'YOUR_TRANSLOADIT_KEY',
|
335
|
+
:secret => 'YOUR_TRANSLOADIT_SECRET'
|
336
|
+
)
|
337
|
+
|
338
|
+
template = transloadit.template
|
339
|
+
|
270
340
|
# returns a list of all templates.
|
271
341
|
template.list
|
272
342
|
|
@@ -293,57 +363,63 @@ template.delete 'YOUR_TEMPLATE_ID'
|
|
293
363
|
|
294
364
|
### 9. Getting Bill reports
|
295
365
|
|
296
|
-
If you want to retrieve your
|
366
|
+
If you want to retrieve your Transloadit account billing report for a particular month and year
|
297
367
|
you can use the `bill` method passing the required month and year like the following:
|
298
368
|
|
299
369
|
```ruby
|
370
|
+
require 'transloadit'
|
371
|
+
|
372
|
+
transloadit = Transloadit.new(
|
373
|
+
:key => 'YOUR_TRANSLOADIT_KEY',
|
374
|
+
:secret => 'YOUR_TRANSLOADIT_SECRET'
|
375
|
+
)
|
376
|
+
|
300
377
|
# returns bill report for February, 2016.
|
301
378
|
transloadit.bill(2, 2016)
|
302
379
|
```
|
380
|
+
|
303
381
|
Not specifying the `month` or `year` would default to the current month or year.
|
304
382
|
|
305
383
|
### 10. Rate limits
|
306
384
|
|
307
385
|
Transloadit enforces rate limits to guarantee that no customers are adversely affected by the usage
|
308
|
-
of any given customer. See [Rate Limiting](https://transloadit.com/docs/api
|
386
|
+
of any given customer. See [Rate Limiting](https://transloadit.com/docs/api/#rate-limiting).
|
309
387
|
|
310
|
-
While creating an
|
311
|
-
response. If after these attempts the rate limit error persists, a `RateLimitReached` exception will be raised.
|
388
|
+
While creating an <dfn>Assembly</dfn>, if a rate limit error is received, by default, 2 more attempts would be made for a successful response. If after these attempts the rate limit error persists, a `RateLimitReached` exception will be raised.
|
312
389
|
|
313
|
-
To change the number of attempts that will be made when creating an
|
314
|
-
assembly like so.
|
390
|
+
To change the number of attempts that will be made when creating an <dfn>Assembly</dfn>, you may pass the `tries` option to your <dfn>Assembly</dfn> like so.
|
315
391
|
|
316
392
|
```ruby
|
393
|
+
require 'transloadit'
|
394
|
+
|
395
|
+
transloadit = Transloadit.new(
|
396
|
+
:key => 'YOUR_TRANSLOADIT_KEY',
|
397
|
+
:secret => 'YOUR_TRANSLOADIT_SECRET'
|
398
|
+
)
|
399
|
+
|
317
400
|
# would make one extra attempt after a failed attempt.
|
318
|
-
transloadit.assembly(:tries => 2).create! open('
|
401
|
+
transloadit.assembly(:tries => 2).create! open('/PATH/TO/FILE.mpg')
|
319
402
|
|
320
403
|
# Would make no attempt at all. Your request would not be sent.
|
321
|
-
transloadit.assembly(:tries => 0).create! open('
|
404
|
+
transloadit.assembly(:tries => 0).create! open('/PATH/TO/FILE.mpg')
|
322
405
|
```
|
323
406
|
|
324
|
-
##
|
407
|
+
## Example
|
325
408
|
|
326
|
-
|
327
|
-
|
328
|
-
for the latest [git master](http://rubydoc.info/github/transloadit/ruby-sdk/master/frames).
|
409
|
+
A small sample tutorial of using the Transloadit ruby-sdk to optimize an image, encode MP3 audio, add ID3 tags,
|
410
|
+
and more can be found [here](https://github.com/transloadit/ruby-sdk/tree/main/examples).
|
329
411
|
|
330
|
-
##
|
412
|
+
## Documentation
|
331
413
|
|
332
|
-
|
333
|
-
|
414
|
+
Up-to-date YARD documentation is automatically generated. You can view the
|
415
|
+
docs for the <a href="https://rubydoc.info/gems/transloadit/frames" rel="canonical">released gem</a> or
|
416
|
+
for the latest [git main](https://rubydoc.info/github/transloadit/ruby-sdk/main/frames).
|
334
417
|
|
335
418
|
## Compatibility
|
336
419
|
|
337
|
-
|
338
|
-
|
339
|
-
Rubies is not guaranteed. If it doesn't work on one of the officially supported Rubies, please file a
|
340
|
-
[bug report](https://github.com/transloadit/ruby-sdk/issues). Compatibility patches for other Rubies
|
341
|
-
are welcome.
|
342
|
-
|
343
|
-
Testing against these versions is performed automatically by
|
344
|
-
[Travis CI](https://travis-ci.org/transloadit/ruby-sdk).
|
420
|
+
Please see [ci.yml](https://github.com/transloadit/ruby-sdk/tree/main/.github/workflows/ci.yml) for a list of supported ruby versions. It may also work on older Rubies, but support for those is not guaranteed. If it doesn't work on one of the officially supported Rubies, please file a
|
421
|
+
[bug report](https://github.com/transloadit/ruby-sdk/issues). Compatibility patches for other Rubies are welcome.
|
345
422
|
|
346
|
-
### Ruby
|
423
|
+
### Ruby 2.x
|
347
424
|
|
348
|
-
If you still need support for
|
349
|
-
supports those.
|
425
|
+
If you still need support for Ruby 2.x, 2.0.1 is the last version that supports it.
|