shrine-transloadit 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4f6c9f75eb5ae136a186f42f8b3e255b37e75922
4
- data.tar.gz: e25b2ed74f6e742c82539a86b8f9814497978947
3
+ metadata.gz: 598fedd796007106bdd2326f56bd2d7b1f4e56eb
4
+ data.tar.gz: 4b81b6377ac2fbe38d1ee87b77632791e2ddad2e
5
5
  SHA512:
6
- metadata.gz: f0279efcd3b9de0a223f258e03cb1689490d9f84225ce43fce35b9b7f8e3cd78514577bdcfe09d40e252b50e69a3135cf0be575ec32e2d6a7dd2217933988598
7
- data.tar.gz: bb661843d2b3886a66aaca015d98eb6caef0317b1a6171d3581b008c0d2fbec1f5249ec9671d36b6b8c0ce0447ab98e0bf29a0c912e2ded7014a164a41ae34d8
6
+ metadata.gz: e98531a56617650480632a49553633da208bac6f0a298f7b0106db7f9320c591e30020dfb52cd7dc48c23163d0ac1c7cbdc6303abdc09fc79c47d1e171a5c7e7
7
+ data.tar.gz: ae68d0319caefad44c01e5d73cb16a78fd7fa3343bca750a765a0ea68d00633ef5b611f65eed866655030517e82dddb77af3579570426d4023989d2be528e903
data/README.md CHANGED
@@ -108,6 +108,33 @@ class MyUploader < Shrine
108
108
  end
109
109
  ```
110
110
 
111
+ ### Webhooks
112
+
113
+ Transloadit performs its processing asynchronously, and you can provide a URL
114
+ where you want Transloadit to POST results of processing once it's finished.
115
+
116
+ ```rb
117
+ class MyUploader < Shrine
118
+ def transloadit_process(io, context)
119
+ # ...
120
+
121
+ transloadit_assembly(files, notify_url: "http://myapp.com/webhooks/transloadit")
122
+ end
123
+ end
124
+ ```
125
+
126
+ Then in your `POST /webhooks/transloadit` route you can call the plugin to
127
+ automatically save the results to the attachment column in Shrine's format.
128
+
129
+ ```rb
130
+ post "/webhooks/transloadit" do
131
+ Shrine::Attacher.transloadit_save(params)
132
+ end
133
+ ```
134
+
135
+ Note that if you have CSRF protection, make sure that you skip verifying the
136
+ CSRF token for this route.
137
+
111
138
  ### Direct uploads
112
139
 
113
140
  Transloadit supports direct uploads, allowing you to do additional processing
@@ -182,30 +209,6 @@ class MyUploader < Shrine
182
209
  end
183
210
  ```
184
211
 
185
- ### Webhooks
186
-
187
- Transloadit performs its processing asynchronously, and you can provide a URL
188
- where you want Transloadit to POST results of processing once it's finished.
189
-
190
- ```rb
191
- class MyUploader < Shrine
192
- def transloadit_process(io, context)
193
- # ...
194
-
195
- transloadit_assembly(files, notify_url: "http://myapp.com/webhooks/transloadit")
196
- end
197
- end
198
- ```
199
-
200
- Then in your `POST /webhooks/transloadit` route you can call the plugin to
201
- automatically save the results to the attachment column in Shrine's format.
202
-
203
- ```rb
204
- post "/webhooks/transloadit" do
205
- Shrine::Attacher.transloadit_save(params)
206
- end
207
- ```
208
-
209
212
  ### Backgrounding
210
213
 
211
214
  Even though submitting a Transloadit assembly doesn't require any uploading, it
@@ -109,7 +109,7 @@ class Shrine
109
109
  if valid
110
110
  swap(stored_file)
111
111
  else
112
- _delete(stored_file, phase: :abort)
112
+ _delete(stored_file, action: :abort)
113
113
  end
114
114
  end
115
115
  end
@@ -139,7 +139,7 @@ class Shrine
139
139
  when /amazonaws\.com/
140
140
  raise Error, "Cannot save a processed file which wasn't exported: #{url.inspect}" if url.include?("tmp.transloadit.com")
141
141
  path = URI(url).path
142
- id = path.match(/^\/#{storage.prefix}/).post_match
142
+ id = path.match(%r{^(/#{storage.prefix})?/}).post_match
143
143
  else
144
144
  raise Error, "The transloadit Shrine plugin doesn't support storage identified by #{url.inspect}"
145
145
  end
@@ -194,13 +194,16 @@ class Shrine
194
194
 
195
195
  # Generates an export step from the current (permanent) storage.
196
196
  # At the moment only Amazon S3 is supported.
197
- def transloadit_export_step(name, **step_options)
197
+ def transloadit_export_step(name, path: nil, **step_options)
198
198
  if defined?(Storage::S3) && storage.is_a?(Storage::S3)
199
+ path ||= "${unique_prefix}/${file.url_name}" # Transloadit's default path
200
+
199
201
  step = transloadit.step(name, "/s3/store",
200
202
  key: storage.s3.client.config.access_key_id,
201
203
  secret: storage.s3.client.config.secret_access_key,
202
204
  bucket: storage.bucket.name,
203
- bucket_region: storage.s3.client.config.region
205
+ bucket_region: storage.s3.client.config.region,
206
+ path: [*storage.prefix, path].join("/"),
204
207
  )
205
208
  else
206
209
  raise Error, "Cannot construct a transloadit export step from #{storage.inspect}"
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "shrine-transloadit"
3
- gem.version = "0.4.0"
3
+ gem.version = "0.4.1"
4
4
 
5
5
  gem.required_ruby_version = ">= 2.1"
6
6
 
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
13
13
  gem.files = Dir["README.md", "LICENSE.txt", "lib/**/*.rb", "*.gemspec"]
14
14
  gem.require_path = "lib"
15
15
 
16
- gem.add_dependency "shrine", "~> 2.1"
16
+ gem.add_dependency "shrine", "~> 2.2"
17
17
  gem.add_dependency "transloadit", "~> 1.2"
18
18
 
19
19
  gem.add_development_dependency "rake"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shrine-transloadit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-12 00:00:00.000000000 Z
11
+ date: 2016-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shrine
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.1'
19
+ version: '2.2'
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: '2.1'
26
+ version: '2.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: transloadit
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -172,4 +172,3 @@ signing_key:
172
172
  specification_version: 4
173
173
  summary: Provides Transloadit integration for Shrine.
174
174
  test_files: []
175
- has_rdoc: