transloadit 3.0.2 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.dockerignore +9 -0
- data/.gitattributes +2 -0
- data/.github/workflows/ci.yml +49 -6
- data/.gitignore +4 -0
- data/.vscode/ruby-sdk.code-workspace +13 -0
- data/CHANGELOG.md +9 -0
- data/CONTRIBUTING.md +95 -0
- data/Dockerfile +19 -0
- data/Gemfile +5 -0
- data/Makefile +18 -0
- data/README.md +89 -44
- data/chameleon.jpg +0 -0
- data/lib/transloadit/assembly.rb +2 -2
- data/lib/transloadit/response.rb +1 -0
- data/lib/transloadit/step.rb +1 -1
- data/lib/transloadit/template.rb +1 -1
- data/lib/transloadit/version.rb +1 -1
- data/lib/transloadit.rb +54 -1
- data/scripts/notify-registry.sh +57 -0
- data/scripts/test-in-docker.sh +89 -0
- data/test/integration/test_e2e_upload.rb +97 -0
- data/test/test_helper.rb +55 -2
- data/test/unit/test_transloadit.rb +4 -1
- data/test/unit/transloadit/test_assembly.rb +1 -1
- data/test/unit/transloadit/test_request.rb +85 -0
- data/test/unit/transloadit/test_smart_cdn.rb +158 -0
- data/transloadit.gemspec +2 -2
- metadata +16 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c48cbed2048f296ca130e4cbb69790fea92b7a02fab75f4aa9c0e6811b89063e
|
|
4
|
+
data.tar.gz: 2b9752757ce8a2575cb6b3c446a19aec436c4003e715869e835e8906fb768b85
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2d05074cb025387b2f805c14797ff93b9abd5b28f77b51bc7a6a69811d66deb2dad2260a0ad6f0ad7ea5ff4313e076d1867332528a5b136f6694267d56987eee
|
|
7
|
+
data.tar.gz: e078c99468b14f03ddc1f1c48a7abab1f92492194d8fc17bb6208a696f0a0cfb9a638a4002f7a4905ef9cd714e6ba0159f4f7f6e275693527478d5ea1ff3eae6
|
data/.dockerignore
ADDED
data/.gitattributes
ADDED
data/.github/workflows/ci.yml
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
name: CI
|
|
2
2
|
on:
|
|
3
3
|
push:
|
|
4
|
-
branches:
|
|
4
|
+
branches:
|
|
5
|
+
- main
|
|
5
6
|
pull_request:
|
|
6
|
-
|
|
7
|
+
types:
|
|
8
|
+
- opened
|
|
9
|
+
- synchronize
|
|
7
10
|
jobs:
|
|
8
11
|
ci:
|
|
9
12
|
runs-on: ubuntu-latest
|
|
@@ -13,15 +16,55 @@ jobs:
|
|
|
13
16
|
- 3.0
|
|
14
17
|
- 3.1
|
|
15
18
|
- 3.2
|
|
19
|
+
- 3.3
|
|
16
20
|
- jruby
|
|
17
|
-
# - jruby-head
|
|
18
21
|
- truffleruby
|
|
19
|
-
|
|
22
|
+
fail-fast: false
|
|
20
23
|
steps:
|
|
21
|
-
- uses: actions/checkout@
|
|
24
|
+
- uses: actions/checkout@v3
|
|
25
|
+
- uses: actions/setup-node@v4
|
|
26
|
+
with:
|
|
27
|
+
node-version: 20
|
|
28
|
+
- run: npm install -g tsx
|
|
22
29
|
- uses: ruby/setup-ruby@v1
|
|
23
30
|
with:
|
|
24
31
|
ruby-version: ${{ matrix.ruby }}
|
|
25
32
|
bundler-cache: true
|
|
26
33
|
- run: bundle exec standardrb
|
|
27
|
-
-
|
|
34
|
+
- name: Run tests
|
|
35
|
+
env:
|
|
36
|
+
COVERAGE: ${{ matrix.ruby == '3.3' && '1' || '0' }}
|
|
37
|
+
TEST_NODE_PARITY: ${{ matrix.ruby == '3.3' && '1' || '0' }}
|
|
38
|
+
run: bundle exec rake test
|
|
39
|
+
- name: Upload coverage to Codecov
|
|
40
|
+
if: matrix.ruby == '3.3'
|
|
41
|
+
uses: codecov/codecov-action@v5
|
|
42
|
+
with:
|
|
43
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
44
|
+
files: ./coverage/coverage.json
|
|
45
|
+
fail_ci_if_error: true
|
|
46
|
+
e2e:
|
|
47
|
+
needs: ci
|
|
48
|
+
if: >
|
|
49
|
+
github.event_name != 'pull_request' ||
|
|
50
|
+
github.event.pull_request.head.repo.full_name == github.repository
|
|
51
|
+
runs-on: ubuntu-latest
|
|
52
|
+
env:
|
|
53
|
+
TRANSLOADIT_KEY: ${{ secrets.TRANSLOADIT_KEY }}
|
|
54
|
+
TRANSLOADIT_SECRET: ${{ secrets.TRANSLOADIT_SECRET }}
|
|
55
|
+
steps:
|
|
56
|
+
- uses: actions/checkout@v3
|
|
57
|
+
- uses: ruby/setup-ruby@v1
|
|
58
|
+
with:
|
|
59
|
+
ruby-version: 3.3
|
|
60
|
+
bundler-cache: true
|
|
61
|
+
- name: Ensure e2e credentials are configured
|
|
62
|
+
if: ${{ env.TRANSLOADIT_KEY == '' || env.TRANSLOADIT_SECRET == '' }}
|
|
63
|
+
run: |
|
|
64
|
+
echo "TRANSLOADIT_KEY and TRANSLOADIT_SECRET must be configured in repository secrets to run the e2e job." >&2
|
|
65
|
+
exit 1
|
|
66
|
+
- name: Run end-to-end upload test
|
|
67
|
+
env:
|
|
68
|
+
RUBY_SDK_E2E: 1
|
|
69
|
+
if: ${{ env.TRANSLOADIT_KEY != '' && env.TRANSLOADIT_SECRET != '' }}
|
|
70
|
+
run: bundle exec ruby -Itest test/integration/test_e2e_upload.rb
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
### 3.1.1 / 2025-10-28
|
|
2
|
+
|
|
3
|
+
- Add optional live end-to-end upload harness and CI job for parity verification, defaulted in Docker tests (kvz)
|
|
4
|
+
- Restore missing `require "uri"` to prevent `NameError` when loading `Transloadit::Request` (kvz)
|
|
5
|
+
|
|
6
|
+
### 3.1.0 / 2024-11-24
|
|
7
|
+
|
|
8
|
+
- Add Smart CDN signature support via `signed_smart_cdn_url` method (kvz)
|
|
9
|
+
|
|
1
10
|
### 3.0.2 / 2024-03-01
|
|
2
11
|
|
|
3
12
|
- Upgrade signature algorithm to more secure SHA-384 [#69](https://github.com/transloadit/ruby-sdk/pull/69) (@aduh95)
|
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for helping improve the Transloadit Ruby SDK! This guide covers local development, testing, and publishing new releases.
|
|
4
|
+
|
|
5
|
+
## Local Development
|
|
6
|
+
|
|
7
|
+
After cloning the repository, install dependencies and run the test suite:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
bundle install
|
|
11
|
+
bundle exec rake test
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
To exercise the signature parity suite against the Node.js CLI, make sure `npx transloadit` is available and run:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
TEST_NODE_PARITY=1 bundle exec rake test
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
You can warm the CLI cache ahead of time:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
TRANSLOADIT_KEY=... TRANSLOADIT_SECRET=... \
|
|
24
|
+
npx --yes transloadit smart_sig --help
|
|
25
|
+
TRANSLOADIT_KEY=... TRANSLOADIT_SECRET=... \
|
|
26
|
+
npx --yes transloadit sig --algorithm sha384 --help
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Set `COVERAGE=0` to skip coverage instrumentation if desired:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
COVERAGE=0 bundle exec rake test
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Docker Workflow
|
|
36
|
+
|
|
37
|
+
The repository ships with a helper that runs tests inside a reproducible Docker image:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
./scripts/test-in-docker.sh
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Pass a custom command to run alternatives (Bundler still installs first):
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
./scripts/test-in-docker.sh bundle exec ruby -Itest test/unit/transloadit/test_request.rb
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The script forwards environment variables such as `TEST_NODE_PARITY` and credentials from `.env`, so you can combine parity checks and integration tests. End-to-end uploads are enabled by default; unset them by running:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
RUBY_SDK_E2E=0 ./scripts/test-in-docker.sh
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Live End-to-End Test
|
|
56
|
+
|
|
57
|
+
To exercise the optional live upload:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
RUBY_SDK_E2E=1 TRANSLOADIT_KEY=... TRANSLOADIT_SECRET=... \
|
|
61
|
+
./scripts/test-in-docker.sh bundle exec ruby -Itest test/integration/test_e2e_upload.rb
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The test uploads `chameleon.jpg`, resizes it, and asserts on a real assembly response.
|
|
65
|
+
|
|
66
|
+
## Releasing to RubyGems
|
|
67
|
+
|
|
68
|
+
1. Update the version and changelog:
|
|
69
|
+
- Bump `lib/transloadit/version.rb`.
|
|
70
|
+
- Add a corresponding entry to `CHANGELOG.md`.
|
|
71
|
+
2. Run the full test suite (including Docker, parity, and e2e checks as needed).
|
|
72
|
+
3. Commit the release changes and tag:
|
|
73
|
+
```bash
|
|
74
|
+
git commit -am "Release X.Y.Z"
|
|
75
|
+
git tag -a vX.Y.Z -m "Release X.Y.Z"
|
|
76
|
+
```
|
|
77
|
+
4. Push the commit and tag:
|
|
78
|
+
```bash
|
|
79
|
+
git push origin main
|
|
80
|
+
git push origin vX.Y.Z
|
|
81
|
+
```
|
|
82
|
+
5. Publish the gem using the helper script:
|
|
83
|
+
```bash
|
|
84
|
+
GEM_HOST_API_KEY=... ./scripts/notify-registry.sh
|
|
85
|
+
```
|
|
86
|
+
6. Draft a GitHub release from the new tag and publish the generated notes.
|
|
87
|
+
|
|
88
|
+
### RubyGems Credentials
|
|
89
|
+
|
|
90
|
+
- You must belong to the `transloadit` organization on RubyGems with permission to push the `transloadit` gem.
|
|
91
|
+
- Generate an API key with **Push Rubygems** permissions at <https://rubygems.org/profile/edit>. Copy the token and keep it secure.
|
|
92
|
+
- Export the token as `GEM_HOST_API_KEY` in your environment before running `./scripts/notify-registry.sh`. The script refuses to run if the variable is missing.
|
|
93
|
+
|
|
94
|
+
That’s it! Thank you for contributing.
|
|
95
|
+
|
data/Dockerfile
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# syntax=docker/dockerfile:1
|
|
2
|
+
|
|
3
|
+
FROM ruby:3.3 AS base
|
|
4
|
+
|
|
5
|
+
RUN apt-get update \
|
|
6
|
+
&& apt-get install -y --no-install-recommends \
|
|
7
|
+
build-essential \
|
|
8
|
+
git \
|
|
9
|
+
curl \
|
|
10
|
+
ca-certificates \
|
|
11
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
12
|
+
|
|
13
|
+
# Install Node.js for parity checks
|
|
14
|
+
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
|
|
15
|
+
&& apt-get install -y --no-install-recommends nodejs \
|
|
16
|
+
&& npm install -g npm@latest \
|
|
17
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
18
|
+
|
|
19
|
+
WORKDIR /workspace
|
data/Gemfile
CHANGED
data/Makefile
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.PHONY: all test fix
|
|
2
|
+
|
|
3
|
+
all: fix test
|
|
4
|
+
|
|
5
|
+
# Run tests
|
|
6
|
+
test:
|
|
7
|
+
bundle exec rake test
|
|
8
|
+
|
|
9
|
+
# Fix code formatting
|
|
10
|
+
fix:
|
|
11
|
+
bundle exec standardrb --fix
|
|
12
|
+
|
|
13
|
+
# Install dependencies
|
|
14
|
+
install:
|
|
15
|
+
bundle install
|
|
16
|
+
|
|
17
|
+
# Run both fix and test
|
|
18
|
+
check: fix test
|
data/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[](https://github.com/transloadit/ruby-sdk/actions/workflows/ci.yml)
|
|
2
|
-
[](https://codecov.io/gh/transloadit/ruby-sdk)
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
# Transloadit Ruby SDK
|
|
5
5
|
|
|
6
6
|
A **Ruby** Integration for [Transloadit](https://transloadit.com)'s file uploading and encoding service
|
|
7
7
|
|
|
@@ -11,7 +11,7 @@ A **Ruby** Integration for [Transloadit](https://transloadit.com)'s file uploadi
|
|
|
11
11
|
|
|
12
12
|
This is a **Ruby** SDK to make it easy to talk to the [Transloadit](https://transloadit.com) REST API.
|
|
13
13
|
|
|
14
|
-
|
|
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)._
|
|
15
15
|
|
|
16
16
|
## Install
|
|
17
17
|
|
|
@@ -29,14 +29,14 @@ $ irb -rubygems
|
|
|
29
29
|
=> true
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
Then create a Transloadit instance, which will maintain your
|
|
33
|
-
[authentication credentials](https://transloadit.com/accounts/credentials)
|
|
32
|
+
Then create a Transloadit instance, which will maintain your
|
|
33
|
+
[authentication credentials](https://transloadit.com/accounts/credentials)
|
|
34
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 => 'MY_TRANSLOADIT_KEY',
|
|
39
|
+
:secret => 'MY_TRANSLOADIT_SECRET'
|
|
40
40
|
)
|
|
41
41
|
```
|
|
42
42
|
|
|
@@ -49,8 +49,8 @@ and store the result on [Amazon S3](https://aws.amazon.com/s3/).
|
|
|
49
49
|
require 'transloadit'
|
|
50
50
|
|
|
51
51
|
transloadit = Transloadit.new(
|
|
52
|
-
:key => '
|
|
53
|
-
:secret => '
|
|
52
|
+
:key => 'MY_TRANSLOADIT_KEY',
|
|
53
|
+
:secret => 'MY_TRANSLOADIT_SECRET'
|
|
54
54
|
)
|
|
55
55
|
|
|
56
56
|
# First, we create two steps: one to resize the image to 320x240, and another to
|
|
@@ -60,9 +60,9 @@ resize = transloadit.step 'resize', '/image/resize',
|
|
|
60
60
|
:height => 240
|
|
61
61
|
|
|
62
62
|
store = transloadit.step 'store', '/s3/store',
|
|
63
|
-
:key => '
|
|
64
|
-
:secret => '
|
|
65
|
-
:bucket => '
|
|
63
|
+
:key => 'MY_AWS_KEY',
|
|
64
|
+
:secret => 'MY_AWS_SECRET',
|
|
65
|
+
:bucket => 'MY_S3_BUCKET'
|
|
66
66
|
|
|
67
67
|
# Now that we have the steps, we create an assembly (which is just a request to
|
|
68
68
|
# process a file or set of files) and let Transloadit do the rest.
|
|
@@ -125,7 +125,7 @@ API at the time the <dfn>Assembly</dfn> was created. You have to explicitly ask
|
|
|
125
125
|
# reloads the response's contents from the REST API
|
|
126
126
|
response.reload!
|
|
127
127
|
|
|
128
|
-
# reloads once per second until all processing is finished, up to number of
|
|
128
|
+
# reloads once per second until all processing is finished, up to number of
|
|
129
129
|
# times specified in :tries option, otherwise will raise ReloadLimitReached
|
|
130
130
|
response.reload_until_finished! tries: 300 # default is 600
|
|
131
131
|
```
|
|
@@ -147,8 +147,8 @@ than one file in the same request. You can also pass a single <dfn>Step</dfn> fo
|
|
|
147
147
|
require 'transloadit'
|
|
148
148
|
|
|
149
149
|
transloadit = Transloadit.new(
|
|
150
|
-
:key => '
|
|
151
|
-
:secret => '
|
|
150
|
+
:key => 'MY_TRANSLOADIT_KEY',
|
|
151
|
+
:secret => 'MY_TRANSLOADIT_SECRET'
|
|
152
152
|
)
|
|
153
153
|
|
|
154
154
|
assembly = transloadit.assembly(steps: store)
|
|
@@ -160,7 +160,7 @@ response = assembly.create!(
|
|
|
160
160
|
)
|
|
161
161
|
```
|
|
162
162
|
|
|
163
|
-
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
164
|
Just unpack the array using the splat `*` operator.
|
|
165
165
|
|
|
166
166
|
```ruby
|
|
@@ -178,8 +178,8 @@ simply need to `use` other <dfn>Steps</dfn>. Following
|
|
|
178
178
|
require 'transloadit'
|
|
179
179
|
|
|
180
180
|
transloadit = Transloadit.new(
|
|
181
|
-
:key => '
|
|
182
|
-
:secret => '
|
|
181
|
+
:key => 'MY_TRANSLOADIT_KEY',
|
|
182
|
+
:secret => 'MY_TRANSLOADIT_SECRET'
|
|
183
183
|
)
|
|
184
184
|
|
|
185
185
|
encode = transloadit.step 'encode', '/video/encode', { ... }
|
|
@@ -208,17 +208,17 @@ for recurring encoding tasks. In order to use these do the following:
|
|
|
208
208
|
require 'transloadit'
|
|
209
209
|
|
|
210
210
|
transloadit = Transloadit.new(
|
|
211
|
-
:key => '
|
|
212
|
-
:secret => '
|
|
211
|
+
:key => 'MY_TRANSLOADIT_KEY',
|
|
212
|
+
:secret => 'MY_TRANSLOADIT_SECRET'
|
|
213
213
|
)
|
|
214
214
|
|
|
215
215
|
transloadit.assembly(
|
|
216
|
-
:template_id => '
|
|
216
|
+
:template_id => 'MY_TEMPLATE_ID'
|
|
217
217
|
).create! open('/PATH/TO/FILE.mpg')
|
|
218
218
|
```
|
|
219
219
|
|
|
220
220
|
You can use your steps together with this template and even use variables.
|
|
221
|
-
The [Transloadit documentation](https://transloadit.com/docs/#passing-variables-into-a-template)
|
|
221
|
+
The [Transloadit documentation](https://transloadit.com/docs/#passing-variables-into-a-template)
|
|
222
222
|
has some nice examples for that.
|
|
223
223
|
|
|
224
224
|
### 5. Using fields
|
|
@@ -231,8 +231,8 @@ to the upload itself. You can use fields like the following:
|
|
|
231
231
|
require 'transloadit'
|
|
232
232
|
|
|
233
233
|
transloadit = Transloadit.new(
|
|
234
|
-
:key => '
|
|
235
|
-
:secret => '
|
|
234
|
+
:key => 'MY_TRANSLOADIT_KEY',
|
|
235
|
+
:secret => 'MY_TRANSLOADIT_SECRET'
|
|
236
236
|
)
|
|
237
237
|
|
|
238
238
|
transloadit.assembly(
|
|
@@ -252,8 +252,8 @@ a Notify URL for the <dfn>Assembly</dfn>.
|
|
|
252
252
|
require 'transloadit'
|
|
253
253
|
|
|
254
254
|
transloadit = Transloadit.new(
|
|
255
|
-
:key => '
|
|
256
|
-
:secret => '
|
|
255
|
+
:key => 'MY_TRANSLOADIT_KEY',
|
|
256
|
+
:secret => 'MY_TRANSLOADIT_SECRET'
|
|
257
257
|
)
|
|
258
258
|
|
|
259
259
|
transloadit.assembly(
|
|
@@ -271,8 +271,8 @@ Transloadit also provides methods to retrieve/replay <dfn>Assemblies</dfn> and t
|
|
|
271
271
|
require 'transloadit'
|
|
272
272
|
|
|
273
273
|
transloadit = Transloadit.new(
|
|
274
|
-
:key => '
|
|
275
|
-
:secret => '
|
|
274
|
+
:key => 'MY_TRANSLOADIT_KEY',
|
|
275
|
+
:secret => 'MY_TRANSLOADIT_SECRET'
|
|
276
276
|
)
|
|
277
277
|
|
|
278
278
|
assembly = transloadit.assembly
|
|
@@ -281,10 +281,10 @@ assembly = transloadit.assembly
|
|
|
281
281
|
assembly.list
|
|
282
282
|
|
|
283
283
|
# returns a specific assembly
|
|
284
|
-
assembly.get '
|
|
284
|
+
assembly.get 'MY_ASSEMBLY_ID'
|
|
285
285
|
|
|
286
286
|
# replays a specific assembly
|
|
287
|
-
response = assembly.replay '
|
|
287
|
+
response = assembly.replay 'MY_ASSEMBLY_ID'
|
|
288
288
|
# should return true if assembly is replaying and false otherwise.
|
|
289
289
|
response.replaying?
|
|
290
290
|
|
|
@@ -292,7 +292,7 @@ response.replaying?
|
|
|
292
292
|
assembly.get_notifications
|
|
293
293
|
|
|
294
294
|
# replays an assembly notification
|
|
295
|
-
assembly.replay_notification '
|
|
295
|
+
assembly.replay_notification 'MY_ASSEMBLY_ID'
|
|
296
296
|
```
|
|
297
297
|
|
|
298
298
|
### 8. Templates
|
|
@@ -304,8 +304,8 @@ for recurring encoding tasks. Here's how you would create a <dfn>Template</dfn>:
|
|
|
304
304
|
require 'transloadit'
|
|
305
305
|
|
|
306
306
|
transloadit = Transloadit.new(
|
|
307
|
-
:key => '
|
|
308
|
-
:secret => '
|
|
307
|
+
:key => 'MY_TRANSLOADIT_KEY',
|
|
308
|
+
:secret => 'MY_TRANSLOADIT_SECRET'
|
|
309
309
|
)
|
|
310
310
|
|
|
311
311
|
template = transloadit.template
|
|
@@ -331,8 +331,8 @@ There are also some other methods to retrieve, update and delete a <dfn>Template
|
|
|
331
331
|
require 'transloadit'
|
|
332
332
|
|
|
333
333
|
transloadit = Transloadit.new(
|
|
334
|
-
:key => '
|
|
335
|
-
:secret => '
|
|
334
|
+
:key => 'MY_TRANSLOADIT_KEY',
|
|
335
|
+
:secret => 'MY_TRANSLOADIT_SECRET'
|
|
336
336
|
)
|
|
337
337
|
|
|
338
338
|
template = transloadit.template
|
|
@@ -341,11 +341,11 @@ template = transloadit.template
|
|
|
341
341
|
template.list
|
|
342
342
|
|
|
343
343
|
# returns a specific template.
|
|
344
|
-
template.get '
|
|
344
|
+
template.get 'MY_TEMPLATE_ID'
|
|
345
345
|
|
|
346
346
|
# updates the template whose id is specified.
|
|
347
347
|
template.update(
|
|
348
|
-
'
|
|
348
|
+
'MY_TEMPLATE_ID',
|
|
349
349
|
:name => 'CHANGED_TEMPLATE_NAME',
|
|
350
350
|
:template => {
|
|
351
351
|
:steps => {
|
|
@@ -358,7 +358,7 @@ template.update(
|
|
|
358
358
|
)
|
|
359
359
|
|
|
360
360
|
# deletes a specific template
|
|
361
|
-
template.delete '
|
|
361
|
+
template.delete 'MY_TEMPLATE_ID'
|
|
362
362
|
```
|
|
363
363
|
|
|
364
364
|
### 9. Getting Bill reports
|
|
@@ -370,8 +370,8 @@ you can use the `bill` method passing the required month and year like the follo
|
|
|
370
370
|
require 'transloadit'
|
|
371
371
|
|
|
372
372
|
transloadit = Transloadit.new(
|
|
373
|
-
:key => '
|
|
374
|
-
:secret => '
|
|
373
|
+
:key => 'MY_TRANSLOADIT_KEY',
|
|
374
|
+
:secret => 'MY_TRANSLOADIT_SECRET'
|
|
375
375
|
)
|
|
376
376
|
|
|
377
377
|
# returns bill report for February, 2016.
|
|
@@ -380,7 +380,48 @@ transloadit.bill(2, 2016)
|
|
|
380
380
|
|
|
381
381
|
Not specifying the `month` or `year` would default to the current month or year.
|
|
382
382
|
|
|
383
|
-
### 10.
|
|
383
|
+
### 10. Signing Smart CDN URLs
|
|
384
|
+
|
|
385
|
+
You can generate signed [Smart CDN](https://transloadit.com/services/content-delivery/) URLs using your Transloadit instance:
|
|
386
|
+
|
|
387
|
+
```ruby
|
|
388
|
+
require 'transloadit'
|
|
389
|
+
|
|
390
|
+
transloadit = Transloadit.new(
|
|
391
|
+
:key => 'MY_TRANSLOADIT_KEY',
|
|
392
|
+
:secret => 'MY_TRANSLOADIT_SECRET'
|
|
393
|
+
)
|
|
394
|
+
|
|
395
|
+
# Generate a signed URL using instance credentials
|
|
396
|
+
url = transloadit.signed_smart_cdn_url(
|
|
397
|
+
workspace: "MY_WORKSPACE",
|
|
398
|
+
template: "MY_TEMPLATE",
|
|
399
|
+
input: "avatars/jane.jpg"
|
|
400
|
+
)
|
|
401
|
+
|
|
402
|
+
# Add URL parameters
|
|
403
|
+
url = transloadit.signed_smart_cdn_url(
|
|
404
|
+
workspace: "MY_WORKSPACE",
|
|
405
|
+
template: "MY_TEMPLATE",
|
|
406
|
+
input: "avatars/jane.jpg",
|
|
407
|
+
url_params: {
|
|
408
|
+
width: 100,
|
|
409
|
+
height: 200
|
|
410
|
+
}
|
|
411
|
+
)
|
|
412
|
+
|
|
413
|
+
# Set expiration time
|
|
414
|
+
url = transloadit.signed_smart_cdn_url(
|
|
415
|
+
workspace: "MY_WORKSPACE",
|
|
416
|
+
template: "MY_TEMPLATE",
|
|
417
|
+
input: "avatars/jane.jpg",
|
|
418
|
+
expire_at_ms: 1732550672867 # Specific timestamp
|
|
419
|
+
)
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
The generated URL will be signed using your Transloadit credentials and can be used to access files through the Smart CDN in a secure manner.
|
|
423
|
+
|
|
424
|
+
### 11. Rate limits
|
|
384
425
|
|
|
385
426
|
Transloadit enforces rate limits to guarantee that no customers are adversely affected by the usage
|
|
386
427
|
of any given customer. See [Rate Limiting](https://transloadit.com/docs/api/#rate-limiting).
|
|
@@ -393,8 +434,8 @@ To change the number of attempts that will be made when creating an <dfn>Assembl
|
|
|
393
434
|
require 'transloadit'
|
|
394
435
|
|
|
395
436
|
transloadit = Transloadit.new(
|
|
396
|
-
:key => '
|
|
397
|
-
:secret => '
|
|
437
|
+
:key => 'MY_TRANSLOADIT_KEY',
|
|
438
|
+
:secret => 'MY_TRANSLOADIT_SECRET'
|
|
398
439
|
)
|
|
399
440
|
|
|
400
441
|
# would make one extra attempt after a failed attempt.
|
|
@@ -406,7 +447,7 @@ transloadit.assembly(:tries => 0).create! open('/PATH/TO/FILE.mpg')
|
|
|
406
447
|
|
|
407
448
|
## Example
|
|
408
449
|
|
|
409
|
-
A small sample
|
|
450
|
+
A small sample tutorials of using the Transloadit Ruby SDK to optimize an image, encode MP3 audio, add ID3 tags,
|
|
410
451
|
and more can be found [here](https://github.com/transloadit/ruby-sdk/tree/main/examples).
|
|
411
452
|
|
|
412
453
|
## Documentation
|
|
@@ -423,3 +464,7 @@ Please see [ci.yml](https://github.com/transloadit/ruby-sdk/tree/main/.github/wo
|
|
|
423
464
|
### Ruby 2.x
|
|
424
465
|
|
|
425
466
|
If you still need support for Ruby 2.x, 2.0.1 is the last version that supports it.
|
|
467
|
+
|
|
468
|
+
## Contributing
|
|
469
|
+
|
|
470
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for local development, testing, and release instructions.
|
data/chameleon.jpg
ADDED
|
Binary file
|
data/lib/transloadit/assembly.rb
CHANGED
|
@@ -4,7 +4,7 @@ require "transloadit"
|
|
|
4
4
|
# Represents an Assembly API ready to make calls to the REST API endpoints.
|
|
5
5
|
#
|
|
6
6
|
# See the Transloadit {documentation}[https://transloadit.com/docs/api-docs/#assembly-api]
|
|
7
|
-
# for
|
|
7
|
+
# for further information on Assemblies and available endpoints.
|
|
8
8
|
#
|
|
9
9
|
class Transloadit::Assembly < Transloadit::ApiModel
|
|
10
10
|
DEFAULT_TRIES = 3
|
|
@@ -23,7 +23,7 @@ class Transloadit::Assembly < Transloadit::ApiModel
|
|
|
23
23
|
# at which point Transloadit will process and store the files according to the
|
|
24
24
|
# rules in the Assembly.
|
|
25
25
|
# See the Transloadit {documentation}[https://transloadit.com/docs/building-assembly-instructions]
|
|
26
|
-
# for
|
|
26
|
+
# for further information on Assemblies and their parameters.
|
|
27
27
|
#
|
|
28
28
|
# Accepts as many IO objects as you wish to process in the assembly.
|
|
29
29
|
# The last argument is an optional Hash
|
data/lib/transloadit/response.rb
CHANGED
data/lib/transloadit/step.rb
CHANGED
|
@@ -6,7 +6,7 @@ require "transloadit"
|
|
|
6
6
|
# +options+ specific to the chosen robot.
|
|
7
7
|
#
|
|
8
8
|
# See the Transloadit {documentation}[https://transloadit.com/docs/building-assembly-instructions]
|
|
9
|
-
# for
|
|
9
|
+
# for further information on robot types and their parameters.
|
|
10
10
|
#
|
|
11
11
|
class Transloadit::Step
|
|
12
12
|
# @return [String] the name to give the step
|
data/lib/transloadit/template.rb
CHANGED
|
@@ -4,7 +4,7 @@ require "transloadit"
|
|
|
4
4
|
# Represents a Template API ready to interact with its corresponding REST API.
|
|
5
5
|
#
|
|
6
6
|
# See the Transloadit {documentation}[https://transloadit.com/docs/api-docs/#template-api]
|
|
7
|
-
# for
|
|
7
|
+
# for further information on Templates and their parameters.
|
|
8
8
|
#
|
|
9
9
|
class Transloadit::Template < Transloadit::ApiModel
|
|
10
10
|
#
|
data/lib/transloadit/version.rb
CHANGED