shrine-transloadit 0.3.0 → 0.4.0

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: 6f101f3b58938e3d62d0af2ae6dcd3d7e49d3623
4
- data.tar.gz: 8314af9c2984e0ddf629bb190a499f8bc7d84280
3
+ metadata.gz: 4f6c9f75eb5ae136a186f42f8b3e255b37e75922
4
+ data.tar.gz: e25b2ed74f6e742c82539a86b8f9814497978947
5
5
  SHA512:
6
- metadata.gz: 9f9ab0417eb5087a1d5c3652f8002781b45e0123053ad47b38856bd05755bb55e32585caf22985bb2b9796fcb1165d3fd00af7c36fcdc65b815a614bcc1a39e9
7
- data.tar.gz: 000c35dbf448f1308e4f99f1de673ef71bb9ef6de22bd9b710314277608c10de156c5a74cc94f4bbc5164ea88af84b69dd8afd139d1906484ae95a24629d4b73
6
+ metadata.gz: f0279efcd3b9de0a223f258e03cb1689490d9f84225ce43fce35b9b7f8e3cd78514577bdcfe09d40e252b50e69a3135cf0be575ec32e2d6a7dd2217933988598
7
+ data.tar.gz: bb661843d2b3886a66aaca015d98eb6caef0317b1a6171d3581b008c0d2fbec1f5249ec9671d36b6b8c0ce0447ab98e0bf29a0c912e2ded7014a164a41ae34d8
data/README.md CHANGED
@@ -8,40 +8,41 @@ to various file storage services.
8
8
 
9
9
  ## Setup
10
10
 
11
- While Transloadit is able to export processed files to [many storage
12
- services], this plugin currently supports only Amazon S3 (just because there
13
- are no Shrine integrations written for other services on that list yet).
11
+ While Transloadit is able to export processed files to [many storage services],
12
+ this plugin currently supports only Amazon S3 (just because there are no Shrine
13
+ integrations written for other services on that list yet). You can just add
14
+ shrine-transloadit to your current setup:
14
15
 
15
16
  ```rb
17
+ gem "shrine"
18
+ gem "aws-sdk" # for Amazon S3
16
19
  gem "shrine-transloadit"
17
- gem "aws-sdk"
18
20
  ```
19
21
 
20
22
  ```rb
21
23
  require "shrine"
22
24
  require "shrine/storage/s3"
23
25
 
24
- Shrine.plugin :transloadit,
25
- auth_key: "your transloadit key",
26
- auth_secret: "your transloadit secret"
27
-
28
- Shrine.storages[:store] = Shrine::Storage::S3.new(
29
- access_key_id: "xyz",
30
- secret_access_key: "abc",
26
+ s3_options = {
27
+ bucket: "my-bucket",
31
28
  region: "my-region",
32
- bucket: "my-app",
33
- )
34
- ```
29
+ access_key_id: "abc",
30
+ secret_access_key: "xyz",
31
+ }
35
32
 
36
- ```rb
37
- post "/webhooks/transloadit" do
38
- Shrine::Attacher.transloadit_save(params)
39
- end
33
+ Shrine.storages = {
34
+ cache: Shrine::Storage::S3.new(prefix: "cache", **s3_options),
35
+ store: Shrine::Storage::S3.new(prefix: "store", **s3_options),
36
+ }
37
+
38
+ Shrine.plugin :transloadit,
39
+ auth_key: "your transloadit key",
40
+ auth_secret: "your transloadit secret"
40
41
  ```
41
42
 
42
- This setup assumes you want to do [direct uploads](#direct-uploads) to
43
- Transloadit. This is completely optional, the plugin will work equally well
44
- with whatever your `:cache` storage is.
43
+ This setup assumes you're doing direct S3 uploads, but you can also do [direct
44
+ uploads to Transloadit], or just use any other `:cache` storage which provides
45
+ URLs for uploaded files.
45
46
 
46
47
  ## How it works
47
48
 
@@ -115,9 +116,22 @@ only want to do some light processing on direct uploads, and without any
115
116
  exporting, so that you have better control over your Transloadit bandwidth.
116
117
 
117
118
  When direct upload finishes, Transloadit returns information about the uploaded
118
- file(s). The default `:cache` storage allows you to store Transloadit's
119
- temporary file URL as an attachment. This means that you can use the following
120
- JavaScript to convert Transloadit's data hash into Shrine's format:
119
+ file(s), one of which is a temporary URL to the file. You want to save this URL
120
+ as cached attachment, so that you can display it to the user and use it for
121
+ further Transloadit processing. You can do that using [shrine-url]:
122
+
123
+ ```rb
124
+ gem "shrine-url"
125
+ ```
126
+
127
+ ```rb
128
+ require "shrine/storage/url"
129
+ Shrine.storages[:cache] = Shrine::Storage::Url.new
130
+ ```
131
+
132
+ Now when you obtain results from finished direct uploads on the client-side,
133
+ you need to transform the Transloadit hash into Shrine's uploaded file
134
+ representation, using the URL as the "id":
121
135
 
122
136
  ```js
123
137
  {
@@ -407,3 +421,5 @@ $ bundle exec rake test
407
421
  [templates]: https://transloadit.com/docs/#templates
408
422
  [jQuery plugin]: https://github.com/transloadit/jquery-sdk
409
423
  [demo app]: /demo
424
+ [direct uploads to Transloadit]: #direct-uploads
425
+ [shrine-url]: https://github.com/janko-m/shrine-url
@@ -21,11 +21,6 @@ class Shrine
21
21
  raise Error, "The :auth_key is required for transloadit plugin" if uploader.opts[:transloadit_auth_key].nil?
22
22
  raise Error, "The :auth_secret is required for transloadit plugin" if uploader.opts[:transloadit_auth_secret].nil?
23
23
 
24
- uploader.storages[:cache] ||= (
25
- require "shrine/storage/url"
26
- Shrine::Storage::Url.new
27
- )
28
-
29
24
  uploader.opts[:backgrounding_promote] ||= proc { transloadit_process }
30
25
  end
31
26
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "shrine-transloadit"
3
- gem.version = "0.3.0"
3
+ gem.version = "0.4.0"
4
4
 
5
5
  gem.required_ruby_version = ">= 2.1"
6
6
 
@@ -15,7 +15,6 @@ Gem::Specification.new do |gem|
15
15
 
16
16
  gem.add_dependency "shrine", "~> 2.1"
17
17
  gem.add_dependency "transloadit", "~> 1.2"
18
- gem.add_dependency "shrine-url"
19
18
 
20
19
  gem.add_development_dependency "rake"
21
20
  gem.add_development_dependency "minitest"
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.3.0
4
+ version: 0.4.0
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-11 00:00:00.000000000 Z
11
+ date: 2016-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shrine
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.2'
41
- - !ruby/object:Gem::Dependency
42
- name: shrine-url
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: rake
57
43
  requirement: !ruby/object:Gem::Requirement