cloudinary 1.0.64 → 1.0.65
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/CHANGELOG +7 -0
- data/lib/cloudinary/carrier_wave/preloaded.rb +44 -5
- data/lib/cloudinary/carrier_wave/storage.rb +1 -1
- data/lib/cloudinary/uploader.rb +4 -1
- data/lib/cloudinary/utils.rb +4 -1
- data/lib/cloudinary/version.rb +1 -1
- data/spec/uploader_spec.rb +13 -1
- metadata +8 -16
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NGM4YmEyMGE3NWMyZjliNWJiYzI1OWZhYjU5ZTYxYTk2ZWMzZDMxMg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
OGNhYmI2ZDM3ZWM5NjZhMjJjNDlkY2E0MzkzOTJkZTJkOWNhNmZiNQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NjAyMDk1OTNkNWVmMGFkODkxZDYxNjIxNzRmNThiY2FiNmQ0MjhhMzIwNmMx
|
10
|
+
MmViOGJmMGZkN2Q5ZmFlYmFjZjk4OGY3ZmY1MzU2Mjk5MDQ3ZTBkMmM0YmUz
|
11
|
+
YjYzYjc3ZThlNDVhZDQ1N2VhZTU3OGJiMjczNmI4ZmYwYzc3NTg=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NjExMzBkZGMxMDFmNGI3Y2QzOWI0YTJhMTRhMzE3MWQ3ZWJmZmY0MDBiYjAx
|
14
|
+
NTM5ZDYxYzQ0MzZmOTU4MzhjZWMwYjI3ODMwNzc4NDg1ODBkMzkzNjM2OGFk
|
15
|
+
MWQ2Y2MyZDI4ODAyOWZlNzQwMzUzNjZkYjE5NmM4NTYzMDhlMjU=
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
= Version 1.0.65 - 2013-11-04
|
2
|
+
* Support for unique_filename upload parameter
|
3
|
+
* Support the color parameter
|
4
|
+
* Support for uploading Pathname
|
5
|
+
* Support for stored files
|
6
|
+
* Updated Cloudinary's jQuery plugin to v1.0.11: Support color parameter
|
7
|
+
|
1
8
|
= Version 1.0.64 - 2013-10-17
|
2
9
|
* Extracted upload_tag_params and upload_url from image_upload_tag. Extracted common code to sign_request.
|
3
10
|
* Updated Cloudinary's jQuery plugin to v1.0.10: Binding jQuery file upload events.
|
@@ -4,10 +4,13 @@
|
|
4
4
|
# Where signature is the cloduinary API signature on the public_id and version.
|
5
5
|
module Cloudinary::CarrierWave
|
6
6
|
PRELOADED_CLOUDINARY_PATH = Cloudinary::PreloadedFile::PRELOADED_CLOUDINARY_PATH
|
7
|
+
STORED_CLOUDINARY_PATH = /^([^\/]+)\/([^\/]+)\/v(\d+)\/([^#]+)$/
|
8
|
+
SHORT_STORED_CLOUDINARY_PATH = /^v(\d+)\/([^#]+)$/
|
7
9
|
|
8
10
|
def cache!(new_file)
|
9
|
-
|
10
|
-
|
11
|
+
file = Cloudinary::CarrierWave::createRawOrPreloaded(new_file)
|
12
|
+
if file
|
13
|
+
@file = file
|
11
14
|
@stored_version = @file.version
|
12
15
|
@public_id = @stored_public_id = @file.public_id
|
13
16
|
self.original_filename = sanitize(@file.original_filename)
|
@@ -19,8 +22,9 @@ module Cloudinary::CarrierWave
|
|
19
22
|
end
|
20
23
|
|
21
24
|
def retrieve_from_cache!(new_file)
|
22
|
-
|
23
|
-
|
25
|
+
file = Cloudinary::CarrierWave::createRawOrPreloaded(new_file)
|
26
|
+
if file
|
27
|
+
@file = file
|
24
28
|
@stored_version = @file.version
|
25
29
|
@public_id = @stored_public_id = @file.public_id
|
26
30
|
self.original_filename = sanitize(@file.original_filename)
|
@@ -32,7 +36,7 @@ module Cloudinary::CarrierWave
|
|
32
36
|
end
|
33
37
|
|
34
38
|
def cache_name
|
35
|
-
return @file.is_a?(PreloadedCloudinaryFile) ? @file.to_s : super
|
39
|
+
return (@file.is_a?(PreloadedCloudinaryFile) || @file.is_a?(StoredFile)) ? @file.to_s : super
|
36
40
|
end
|
37
41
|
|
38
42
|
class PreloadedCloudinaryFile < Cloudinary::PreloadedFile
|
@@ -51,4 +55,39 @@ module Cloudinary::CarrierWave
|
|
51
55
|
self.filename
|
52
56
|
end
|
53
57
|
end
|
58
|
+
|
59
|
+
class StoredFile < Cloudinary::PreloadedFile
|
60
|
+
def initialize(file_info)
|
61
|
+
if file_info.match(STORED_CLOUDINARY_PATH)
|
62
|
+
@resource_type, @type, @version, @filename = file_info.scan(STORED_CLOUDINARY_PATH).first
|
63
|
+
elsif file_info.match(SHORT_STORED_CLOUDINARY_PATH)
|
64
|
+
@version, @filename = file_info.scan(SHORT_STORED_CLOUDINARY_PATH).first
|
65
|
+
else
|
66
|
+
raise(ArgumentError, "File #{file_info} is illegal")
|
67
|
+
end
|
68
|
+
@public_id, @format = Cloudinary::PreloadedFile.split_format(@filename)
|
69
|
+
end
|
70
|
+
|
71
|
+
def valid?
|
72
|
+
true
|
73
|
+
end
|
74
|
+
|
75
|
+
def delete
|
76
|
+
# Do nothing. This is a virtual file.
|
77
|
+
end
|
78
|
+
|
79
|
+
def original_filename
|
80
|
+
self.filename
|
81
|
+
end
|
82
|
+
|
83
|
+
def to_s
|
84
|
+
identifier
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.createRawOrPreloaded(file)
|
89
|
+
return file if file.is_a?(Cloudinary::CarrierWave::StoredFile)
|
90
|
+
return PreloadedCloudinaryFile.new(file) if file.is_a?(String) && file.match(PRELOADED_CLOUDINARY_PATH)
|
91
|
+
nil
|
92
|
+
end
|
54
93
|
end
|
@@ -14,7 +14,7 @@ class Cloudinary::CarrierWave::Storage < ::CarrierWave::Storage::Abstract
|
|
14
14
|
store_cloudinary_identifier(file.version, file.filename)
|
15
15
|
end
|
16
16
|
return
|
17
|
-
when Cloudinary::CarrierWave::CloudinaryFile
|
17
|
+
when Cloudinary::CarrierWave::CloudinaryFile, Cloudinary::CarrierWave::StoredFile
|
18
18
|
return nil # Nothing to do
|
19
19
|
when Cloudinary::CarrierWave::RemoteFile
|
20
20
|
data = file.uri.to_s
|
data/lib/cloudinary/uploader.rb
CHANGED
@@ -30,6 +30,7 @@ class Cloudinary::Uploader
|
|
30
30
|
:eager=>build_eager(options[:eager]),
|
31
31
|
:headers=>build_custom_headers(options[:headers]),
|
32
32
|
:use_filename=>Cloudinary::Utils.as_safe_bool(options[:use_filename]),
|
33
|
+
:unique_filename=>Cloudinary::Utils.as_safe_bool(options[:unique_filename]),
|
33
34
|
:discard_original_filename=>Cloudinary::Utils.as_safe_bool(options[:discard_original_filename]),
|
34
35
|
:notification_url=>options[:notification_url],
|
35
36
|
:eager_notification_url=>options[:eager_notification_url],
|
@@ -43,7 +44,9 @@ class Cloudinary::Uploader
|
|
43
44
|
def self.upload(file, options={})
|
44
45
|
call_api("upload", options) do
|
45
46
|
params = build_upload_params(options)
|
46
|
-
if file.
|
47
|
+
if file.is_a?(Pathname)
|
48
|
+
params[:file] = File.open(file, "rb")
|
49
|
+
elsif file.respond_to?(:read) || file =~ /^https?:|^s3:|^data:[^;]*;base64,([a-zA-Z0-9\/+\n=]+)$/
|
47
50
|
params[:file] = file
|
48
51
|
else
|
49
52
|
params[:file] = File.open(file, "rb")
|
data/lib/cloudinary/utils.rb
CHANGED
@@ -35,6 +35,9 @@ class Cloudinary::Utils
|
|
35
35
|
|
36
36
|
background = options.delete(:background)
|
37
37
|
background = background.sub(/^#/, 'rgb:') if background
|
38
|
+
|
39
|
+
color = options.delete(:color)
|
40
|
+
color = color.sub(/^#/, 'rgb:') if color
|
38
41
|
|
39
42
|
base_transformations = build_array(options.delete(:transformation))
|
40
43
|
if base_transformations.any?{|base_transformation| base_transformation.is_a?(Hash)}
|
@@ -59,7 +62,7 @@ class Cloudinary::Utils
|
|
59
62
|
end
|
60
63
|
flags = build_array(options.delete(:flags)).join(".")
|
61
64
|
|
62
|
-
params = {:w=>width, :h=>height, :t=>named_transformation, :c=>crop, :b=>background, :e=>effect, :a=>angle, :bo=>border, :fl=>flags}
|
65
|
+
params = {:w=>width, :h=>height, :t=>named_transformation, :c=>crop, :b=>background, :e=>effect, :a=>angle, :bo=>border, :fl=>flags, :co=>color}
|
63
66
|
{ :x=>:x, :y=>:y, :r=>:radius, :d=>:default_image, :g=>:gravity, :q=>:quality, :cs=>:color_space, :o=>:opacity,
|
64
67
|
:p=>:prefix, :l=>:overlay, :u=>:underlay, :f=>:fetch_format, :dn=>:density, :pg=>:page, :dl=>:delay
|
65
68
|
}.each do
|
data/lib/cloudinary/version.rb
CHANGED
data/spec/uploader_spec.rb
CHANGED
@@ -11,6 +11,11 @@ describe Cloudinary::Uploader do
|
|
11
11
|
expected_signature = Cloudinary::Utils.api_sign_request({:public_id=>result["public_id"], :version=>result["version"]}, Cloudinary.config.api_secret)
|
12
12
|
result["signature"].should == expected_signature
|
13
13
|
end
|
14
|
+
|
15
|
+
it "should successfully upload a file from pathname", :pathname => true do
|
16
|
+
result = Cloudinary::Uploader.upload(Pathname.new("spec/logo.png"))
|
17
|
+
result["width"].should == 241
|
18
|
+
end
|
14
19
|
|
15
20
|
it "should successfully upload file by url" do
|
16
21
|
result = Cloudinary::Uploader.upload("http://cloudinary.com/images/logo.png")
|
@@ -62,5 +67,12 @@ describe Cloudinary::Uploader do
|
|
62
67
|
Cloudinary::Api.resource(result["public_id"])["tags"].should == ["tag2"]
|
63
68
|
Cloudinary::Uploader.replace_tag("tag3", result["public_id"])
|
64
69
|
Cloudinary::Api.resource(result["public_id"])["tags"].should == ["tag3"]
|
65
|
-
end
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should correctly handle unique_filename" do
|
73
|
+
result = Cloudinary::Uploader.upload("spec/logo.png", use_filename: true)
|
74
|
+
result["public_id"].should match(/logo_[a-zA-Z0-9]{6}/)
|
75
|
+
result = Cloudinary::Uploader.upload("spec/logo.png", use_filename: true, unique_filename: false)
|
76
|
+
result["public_id"].should == "logo"
|
77
|
+
end
|
66
78
|
end
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudinary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.65
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Nadav Soferman
|
@@ -11,52 +10,46 @@ authors:
|
|
11
10
|
autorequire:
|
12
11
|
bindir: bin
|
13
12
|
cert_chain: []
|
14
|
-
date: 2013-
|
13
|
+
date: 2013-11-04 00:00:00.000000000 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
|
-
name: rest-client
|
18
16
|
requirement: !ruby/object:Gem::Requirement
|
19
|
-
none: false
|
20
17
|
requirements:
|
21
18
|
- - ! '>='
|
22
19
|
- !ruby/object:Gem::Version
|
23
20
|
version: '0'
|
24
21
|
type: :runtime
|
25
22
|
prerelease: false
|
23
|
+
name: rest-client
|
26
24
|
version_requirements: !ruby/object:Gem::Requirement
|
27
|
-
none: false
|
28
25
|
requirements:
|
29
26
|
- - ! '>='
|
30
27
|
- !ruby/object:Gem::Version
|
31
28
|
version: '0'
|
32
29
|
- !ruby/object:Gem::Dependency
|
33
|
-
name: aws_cf_signer
|
34
30
|
requirement: !ruby/object:Gem::Requirement
|
35
|
-
none: false
|
36
31
|
requirements:
|
37
32
|
- - ! '>='
|
38
33
|
- !ruby/object:Gem::Version
|
39
34
|
version: '0'
|
40
35
|
type: :runtime
|
41
36
|
prerelease: false
|
37
|
+
name: aws_cf_signer
|
42
38
|
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
none: false
|
44
39
|
requirements:
|
45
40
|
- - ! '>='
|
46
41
|
- !ruby/object:Gem::Version
|
47
42
|
version: '0'
|
48
43
|
- !ruby/object:Gem::Dependency
|
49
|
-
name: rspec
|
50
44
|
requirement: !ruby/object:Gem::Requirement
|
51
|
-
none: false
|
52
45
|
requirements:
|
53
46
|
- - ! '>='
|
54
47
|
- !ruby/object:Gem::Version
|
55
48
|
version: '0'
|
56
49
|
type: :development
|
57
50
|
prerelease: false
|
51
|
+
name: rspec
|
58
52
|
version_requirements: !ruby/object:Gem::Requirement
|
59
|
-
none: false
|
60
53
|
requirements:
|
61
54
|
- - ! '>='
|
62
55
|
- !ruby/object:Gem::Version
|
@@ -121,27 +114,26 @@ files:
|
|
121
114
|
homepage: http://cloudinary.com
|
122
115
|
licenses:
|
123
116
|
- MIT
|
117
|
+
metadata: {}
|
124
118
|
post_install_message:
|
125
119
|
rdoc_options: []
|
126
120
|
require_paths:
|
127
121
|
- lib
|
128
122
|
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
123
|
requirements:
|
131
124
|
- - ! '>='
|
132
125
|
- !ruby/object:Gem::Version
|
133
126
|
version: '0'
|
134
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
-
none: false
|
136
128
|
requirements:
|
137
129
|
- - ! '>='
|
138
130
|
- !ruby/object:Gem::Version
|
139
131
|
version: '0'
|
140
132
|
requirements: []
|
141
133
|
rubyforge_project: cloudinary
|
142
|
-
rubygems_version:
|
134
|
+
rubygems_version: 2.0.6
|
143
135
|
signing_key:
|
144
|
-
specification_version:
|
136
|
+
specification_version: 4
|
145
137
|
summary: Client library for easily using the Cloudinary service
|
146
138
|
test_files:
|
147
139
|
- spec/api_spec.rb
|