shrine-cloudinary 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -23
- data/lib/shrine/storage/cloudinary.rb +17 -13
- data/shrine-cloudinary.gemspec +3 -3
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6de8b3f92d35c28abfc92a7ee58478c31aae9e97
|
4
|
+
data.tar.gz: a1ff3ab50a88b2342c3ca5d844a6301338986025
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2367680d167b65e6b267423be706fa5377d555d130e7479c4dbef8bc32720d8cce2b1a10c5ba5a90fe22ae6af85421aca80a46c8aa73f2619fd407b01c38d6e7
|
7
|
+
data.tar.gz: cc68b4752f574e4873b09c896e906da02815aac77844e3eea1023de5688a47914d2187ed723fde038f339eee281a45fea1624545c1ccc5e74a6b105a48a32fbe
|
data/README.md
CHANGED
@@ -63,44 +63,34 @@ specify `:upload_options`:
|
|
63
63
|
Shrine::Storage::Cloudinary.new(upload_options: {type: "authenticated"})
|
64
64
|
```
|
65
65
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
it's possible to trigger file processing on upload. In Shrine you can leverage
|
70
|
-
that by adding `"cloudinary"` metadata, which you can do by overriding
|
71
|
-
`Shrine#extract_metadata`:
|
66
|
+
You can also apply upload options dynamically per upload using the
|
67
|
+
`upload_options` plugin, which is especially useful for doing incoming and
|
68
|
+
eager transformations:
|
72
69
|
|
73
70
|
```rb
|
74
71
|
class MyUploader < Shrine
|
75
|
-
|
76
|
-
|
77
|
-
metadata["cloudinary"] = {
|
72
|
+
plugin :upload_options, store: ->(io, context) do
|
73
|
+
{
|
78
74
|
format: "png",
|
79
75
|
eager: [
|
80
|
-
{
|
81
|
-
{
|
82
|
-
{transformation: "large"},
|
76
|
+
{width: 500, height: 500, crop: :scale},
|
77
|
+
{width: 300, height: 300, crop: :crop, gravity: :south},
|
83
78
|
]
|
84
79
|
}
|
85
|
-
metadata
|
86
80
|
end
|
87
81
|
end
|
88
82
|
```
|
89
83
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
care of by Cloudinary. When displaying the URL the view, you just need to pass
|
94
|
-
in the version name to the uploaded file:
|
84
|
+
### URLs
|
85
|
+
|
86
|
+
You can pass transformation options to the URLs:
|
95
87
|
|
96
88
|
```rb
|
97
|
-
user.avatar_url(
|
98
|
-
user.avatar_url(
|
99
|
-
user.avatar_url(transformation: "large")
|
89
|
+
user.avatar_url(width: 100, height: 100)
|
90
|
+
user.avatar_url(width: 0.2, crop: :scale)
|
100
91
|
```
|
101
92
|
|
102
|
-
|
103
|
-
for all URL options you can pass in.
|
93
|
+
See [Rails image manipulation] for all URL options you can pass in.
|
104
94
|
|
105
95
|
### Large files
|
106
96
|
|
@@ -157,6 +147,9 @@ user.avatar.metadata["cloudinary"] #=>
|
|
157
147
|
# }
|
158
148
|
```
|
159
149
|
|
150
|
+
If you're using the storage directly, `Shrine::Storage::Cloudinary#upload` will
|
151
|
+
return this hash.
|
152
|
+
|
160
153
|
### Clearing storage
|
161
154
|
|
162
155
|
You can delete all files from the Cloudinary storage in the same way as you do
|
@@ -192,3 +185,4 @@ $ bundle exec rake test
|
|
192
185
|
[Cloudinary]: http://cloudinary.com/
|
193
186
|
[Shrine]: https://github.com/janko-m/shrine
|
194
187
|
[Cloudinary options]: http://cloudinary.com/documentation/upload_images#remote_upload
|
188
|
+
[Rails image manipulation]: http://cloudinary.com/documentation/rails_image_manipulation
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require "shrine"
|
1
2
|
require "cloudinary"
|
2
3
|
require "down"
|
3
4
|
|
@@ -19,22 +20,12 @@ class Shrine
|
|
19
20
|
options.update(upload_options)
|
20
21
|
options.update(metadata.delete("cloudinary") || {})
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
result =
|
25
|
-
if remote?(io)
|
26
|
-
uploader.upload(io.storage.url(io.id), **options)
|
27
|
-
else
|
28
|
-
io = io.download if io.is_a?(UploadedFile)
|
29
|
-
if large?(io)
|
30
|
-
uploader.upload_large(io, chunk_size: chunk_size, **options)
|
31
|
-
else
|
32
|
-
uploader.upload(io, **options)
|
33
|
-
end
|
34
|
-
end
|
23
|
+
result = store(io, **options)
|
35
24
|
|
36
25
|
update_id!(result, id)
|
37
26
|
update_metadata!(result, metadata)
|
27
|
+
|
28
|
+
result
|
38
29
|
end
|
39
30
|
|
40
31
|
def download(id)
|
@@ -100,6 +91,19 @@ class Shrine
|
|
100
91
|
|
101
92
|
private
|
102
93
|
|
94
|
+
def store(io, chunk_size: nil, **options)
|
95
|
+
if remote?(io)
|
96
|
+
uploader.upload(io.storage.url(io.id), **options)
|
97
|
+
else
|
98
|
+
io = io.download if io.is_a?(UploadedFile)
|
99
|
+
if large?(io)
|
100
|
+
uploader.upload_large(io, chunk_size: chunk_size, **options)
|
101
|
+
else
|
102
|
+
uploader.upload(io, **options)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
103
107
|
def type
|
104
108
|
upload_options[:type] || "upload"
|
105
109
|
end
|
data/shrine-cloudinary.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
2
|
gem.name = "shrine-cloudinary"
|
3
|
-
gem.version = "0.2.
|
3
|
+
gem.version = "0.2.1"
|
4
4
|
|
5
5
|
gem.required_ruby_version = ">= 2.1"
|
6
6
|
|
@@ -13,11 +13,11 @@ Gem::Specification.new do |gem|
|
|
13
13
|
gem.files = Dir["README.md", "LICENSE.txt", "lib/**/*.rb", "shrine-cloudinary.gemspec"]
|
14
14
|
gem.require_path = "lib"
|
15
15
|
|
16
|
+
gem.add_dependency "shrine", "~> 1.1"
|
16
17
|
gem.add_dependency "cloudinary"
|
17
|
-
gem.add_dependency "down", ">= 1.0.
|
18
|
+
gem.add_dependency "down", ">= 1.0.5"
|
18
19
|
|
19
20
|
gem.add_development_dependency "rake"
|
20
|
-
gem.add_development_dependency "shrine"
|
21
21
|
gem.add_development_dependency "minitest"
|
22
22
|
gem.add_development_dependency "dotenv"
|
23
23
|
end
|
metadata
CHANGED
@@ -1,59 +1,59 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shrine-cloudinary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.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: 2015-12-
|
11
|
+
date: 2015-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: shrine
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '1.1'
|
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: '
|
26
|
+
version: '1.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: cloudinary
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: down
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
48
|
-
type: :
|
47
|
+
version: 1.0.5
|
48
|
+
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 1.0.5
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|