shrine-cloudinary 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 +4 -4
- data/README.md +2 -2
- data/lib/shrine/storage/cloudinary.rb +18 -6
- data/shrine-cloudinary.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12d3db82804fda919a833b89c383245be1231462
|
4
|
+
data.tar.gz: b6445028d38f2702ce59a5e47c8f1dbbc9e7a8ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3683b89aa2464558e29ee230fd16a7aee44cca885b9fc988c453955dfcaade3508baddcf4a94b99c4b017d7e8023e8a7459eff3ddcdb4017fdfc63f4fbd50c87
|
7
|
+
data.tar.gz: fc48706b308d4170b3161c4c1fa468129af7181c8df22c90363fcd043867f68ee62ae64cbb5d05373d776fd82065675e2c77a001478b381cd22afd5a284cf6f7
|
data/README.md
CHANGED
@@ -54,7 +54,7 @@ side, you can generate a presign inline:
|
|
54
54
|
```erb
|
55
55
|
<input name="file" type="file"
|
56
56
|
class="cloudinary-fileupload" data-cloudinary-field="image_id"
|
57
|
-
data-form-data="<%= Shrine.storages[:cache].presign.fields.to_json %>"
|
57
|
+
data-form-data="<%= Shrine.storages[:cache].presign.fields.to_json %>">
|
58
58
|
```
|
59
59
|
|
60
60
|
Alternatively you can add an endpoint to your app which can generate presigns
|
@@ -271,7 +271,7 @@ This gem has been inspired by Cloudinary's [CarrierWave integration].
|
|
271
271
|
[Cloudinary]: http://cloudinary.com/
|
272
272
|
[Shrine]: https://github.com/janko-m/shrine
|
273
273
|
[CarrierWave integration]: https://github.com/cloudinary/cloudinary_gem
|
274
|
-
[Cloudinary options]: http://cloudinary.com/documentation/
|
274
|
+
[Cloudinary options]: http://cloudinary.com/documentation/image_upload_api_reference#upload
|
275
275
|
[Rails image manipulation]: http://cloudinary.com/documentation/rails_image_manipulation
|
276
276
|
[responsive breakpoints]: http://cloudinary.com/blog/introducing_intelligent_responsive_image_breakpoints_solutions
|
277
277
|
[explicit API]: http://cloudinary.com/documentation/image_upload_api_reference#explicit
|
@@ -81,8 +81,8 @@ class Shrine
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def presign(id = nil, **options)
|
84
|
+
upload_options = id ? {public_id: public_id(id)} : {folder: prefix}
|
84
85
|
upload_options.update(@upload_options)
|
85
|
-
upload_options.update(id ? {public_id: public_id(id)} : {folder: prefix})
|
86
86
|
|
87
87
|
fields = ::Cloudinary::Uploader.build_upload_params(upload_options.merge(options))
|
88
88
|
fields.reject! { |key, value| value.nil? || value == "" }
|
@@ -114,15 +114,27 @@ class Shrine
|
|
114
114
|
if remote?(io)
|
115
115
|
::Cloudinary::Uploader.upload(io.url, **options)
|
116
116
|
else
|
117
|
-
io
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
117
|
+
to_file(io) do |file|
|
118
|
+
if large?(file)
|
119
|
+
::Cloudinary::Uploader.upload_large(file, chunk_size: chunk_size, **options)
|
120
|
+
else
|
121
|
+
::Cloudinary::Uploader.upload(file, **options)
|
122
|
+
end
|
122
123
|
end
|
123
124
|
end
|
124
125
|
end
|
125
126
|
|
127
|
+
def to_file(io)
|
128
|
+
if io.is_a?(UploadedFile)
|
129
|
+
file = io.download
|
130
|
+
result = yield file
|
131
|
+
file.delete
|
132
|
+
result
|
133
|
+
else
|
134
|
+
yield io
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
126
138
|
def remote?(io)
|
127
139
|
io.is_a?(UploadedFile) && io.url.to_s =~ /^ftp:|^https?:/
|
128
140
|
end
|
data/shrine-cloudinary.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shrine-cloudinary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
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-06-
|
11
|
+
date: 2016-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shrine
|