cloudinary 1.12.0 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +42 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +21 -0
- data/CHANGELOG.md +62 -0
- data/cloudinary.gemspec +17 -4
- data/lib/active_storage/service/cloudinary_service.rb +58 -16
- data/lib/cloudinary.rb +22 -18
- data/lib/cloudinary/api.rb +3 -2
- data/lib/cloudinary/carrier_wave.rb +2 -1
- data/lib/cloudinary/carrier_wave/remote.rb +2 -2
- data/lib/cloudinary/cloudinary_controller.rb +2 -4
- data/lib/cloudinary/helper.rb +30 -3
- data/lib/cloudinary/railtie.rb +6 -2
- data/lib/cloudinary/uploader.rb +3 -2
- data/lib/cloudinary/utils.rb +12 -9
- data/lib/cloudinary/version.rb +1 -1
- data/vendor/assets/javascripts/cloudinary/jquery.cloudinary.js +2 -2
- metadata +12 -193
- data/spec/access_control_spec.rb +0 -102
- data/spec/active_storage/Gemfile +0 -12
- data/spec/active_storage/application_system_test_case.rb +0 -5
- data/spec/active_storage/database/create_users_migration.rb +0 -9
- data/spec/active_storage/database/setup.rb +0 -7
- data/spec/active_storage/dummy/Rakefile +0 -5
- data/spec/active_storage/dummy/app/assets/config/manifest.js +0 -3
- data/spec/active_storage/dummy/app/assets/javascripts/application.js +0 -13
- data/spec/active_storage/dummy/app/assets/stylesheets/application.css +0 -15
- data/spec/active_storage/dummy/app/controllers/application_controller.rb +0 -5
- data/spec/active_storage/dummy/app/helpers/application_helper.rb +0 -4
- data/spec/active_storage/dummy/app/jobs/application_job.rb +0 -4
- data/spec/active_storage/dummy/app/models/application_record.rb +0 -5
- data/spec/active_storage/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/active_storage/dummy/bin/bundle +0 -5
- data/spec/active_storage/dummy/bin/rails +0 -6
- data/spec/active_storage/dummy/bin/rake +0 -6
- data/spec/active_storage/dummy/bin/yarn +0 -11
- data/spec/active_storage/dummy/config.ru +0 -7
- data/spec/active_storage/dummy/config/application.rb +0 -22
- data/spec/active_storage/dummy/config/boot.rb +0 -7
- data/spec/active_storage/dummy/config/database.yml +0 -25
- data/spec/active_storage/dummy/config/environment.rb +0 -7
- data/spec/active_storage/dummy/config/environments/development.rb +0 -52
- data/spec/active_storage/dummy/config/environments/production.rb +0 -83
- data/spec/active_storage/dummy/config/environments/test.rb +0 -38
- data/spec/active_storage/dummy/config/initializers/application_controller_renderer.rb +0 -7
- data/spec/active_storage/dummy/config/initializers/assets.rb +0 -16
- data/spec/active_storage/dummy/config/initializers/backtrace_silencers.rb +0 -8
- data/spec/active_storage/dummy/config/initializers/cookies_serializer.rb +0 -7
- data/spec/active_storage/dummy/config/initializers/filter_parameter_logging.rb +0 -6
- data/spec/active_storage/dummy/config/initializers/inflections.rb +0 -17
- data/spec/active_storage/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/active_storage/dummy/config/initializers/wrap_parameters.rb +0 -16
- data/spec/active_storage/dummy/config/routes.rb +0 -4
- data/spec/active_storage/dummy/config/secrets.yml +0 -32
- data/spec/active_storage/dummy/config/spring.rb +0 -8
- data/spec/active_storage/dummy/config/storage.yml +0 -3
- data/spec/active_storage/dummy/config/webpacker.yml +0 -72
- data/spec/active_storage/dummy/package.json +0 -5
- data/spec/active_storage/dummy/public/404.html +0 -67
- data/spec/active_storage/dummy/public/422.html +0 -67
- data/spec/active_storage/dummy/public/500.html +0 -66
- data/spec/active_storage/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/active_storage/dummy/public/apple-touch-icon.png +0 -0
- data/spec/active_storage/dummy/public/favicon.ico +0 -0
- data/spec/active_storage/fixtures/files/colors.bmp +0 -0
- data/spec/active_storage/fixtures/files/empty_file.txt +0 -0
- data/spec/active_storage/fixtures/files/favicon.ico +0 -0
- data/spec/active_storage/fixtures/files/icon.psd +0 -0
- data/spec/active_storage/fixtures/files/icon.svg +0 -13
- data/spec/active_storage/fixtures/files/image.gif +0 -0
- data/spec/active_storage/fixtures/files/racecar.jpg +0 -0
- data/spec/active_storage/fixtures/files/racecar.tif +0 -0
- data/spec/active_storage/fixtures/files/racecar_rotated.jpg +0 -0
- data/spec/active_storage/fixtures/files/report.pdf +0 -0
- data/spec/active_storage/fixtures/files/rotated_video.mp4 +0 -0
- data/spec/active_storage/fixtures/files/video.mp4 +0 -0
- data/spec/active_storage/fixtures/files/video_with_rectangular_samples.mp4 +0 -0
- data/spec/active_storage/fixtures/files/video_with_undefined_display_aspect_ratio.mp4 +0 -0
- data/spec/active_storage/fixtures/files/video_without_video_stream.mp4 +0 -0
- data/spec/active_storage/service/cloudinary_service_spec.rb +0 -92
- data/spec/active_storage/service/configurations.yml +0 -4
- data/spec/active_storage/test_helper.rb +0 -43
- data/spec/api_spec.rb +0 -623
- data/spec/archive_spec.rb +0 -145
- data/spec/auth_token_spec.rb +0 -77
- data/spec/cache_spec.rb +0 -109
- data/spec/cloudinary_helper_spec.rb +0 -327
- data/spec/cloudinary_spec.rb +0 -56
- data/spec/data/sync_static/app/assets/javascripts/1.coffee +0 -1
- data/spec/data/sync_static/app/assets/javascripts/1.js +0 -1
- data/spec/data/sync_static/app/assets/stylesheets/1.css +0 -3
- data/spec/docx.docx +0 -0
- data/spec/favicon.ico +0 -0
- data/spec/image_spec.rb +0 -107
- data/spec/logo.png +0 -0
- data/spec/movie.mp4 +0 -0
- data/spec/rake_spec.rb +0 -160
- data/spec/sample_asset_file.tsv +0 -4
- data/spec/search_spec.rb +0 -109
- data/spec/spec_helper.rb +0 -273
- data/spec/storage_spec.rb +0 -44
- data/spec/streaminig_profiles_api_spec.rb +0 -74
- data/spec/support/helpers/temp_file_helpers.rb +0 -22
- data/spec/support/shared_contexts/rake.rb +0 -19
- data/spec/uploader_spec.rb +0 -409
- data/spec/utils_methods_spec.rb +0 -81
- data/spec/utils_spec.rb +0 -1052
- data/spec/video_tag_spec.rb +0 -253
- data/spec/video_url_spec.rb +0 -185
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8c4d1942e462293cb9a3cf7d73878104de63cc041ad6c9a82ae985e9ce1c6dd7
|
|
4
|
+
data.tar.gz: fd09572e0b1be22051a711fb7aacfc1f3f46856531b5c0a3caf50fea49eabae5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 66eea468a7816511382761d6ab667c39b4f90da2c765871d99a69d34091949a3fc8d4d2245cd3b53f18560a99eea59fdd2cdd0173d8e41e6ab8e040236d52dc4
|
|
7
|
+
data.tar.gz: 65c5d8536b106b88f6bf8de3a540df6ffed3f6fed39141d6dfbf47a5ae6b11f3ec37699722e5b20e8fe35c86f452f29ec0ba9b9f5edc776ce81efebbf8cd14f8
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Bug report for Cloudinary Ruby SDK
|
|
4
|
+
title: ''
|
|
5
|
+
labels: ''
|
|
6
|
+
assignees: const-cloudinary
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Bug report for Cloudinary Ruby SDK
|
|
11
|
+
Before proceeding, please update to latest version and test if the issue persists
|
|
12
|
+
|
|
13
|
+
## Describe the bug in a sentence or two.
|
|
14
|
+
…
|
|
15
|
+
|
|
16
|
+
## Issue Type (Can be multiple)
|
|
17
|
+
[ ] Build - Can’t install or import the SDK
|
|
18
|
+
[ ] Performance - Performance issues
|
|
19
|
+
[ ] Behaviour - Functions aren’t working as expected (Such as generate URL)
|
|
20
|
+
[ ] Documentation - Inconsistency between the docs and behaviour
|
|
21
|
+
[ ] Other (Specify)
|
|
22
|
+
|
|
23
|
+
## Steps to reproduce
|
|
24
|
+
… if applicable
|
|
25
|
+
|
|
26
|
+
## Error screenshots or Stack Trace (if applicable)
|
|
27
|
+
…
|
|
28
|
+
|
|
29
|
+
## Operating System
|
|
30
|
+
[ ] Linux
|
|
31
|
+
[ ] Windows
|
|
32
|
+
[ ] OSX
|
|
33
|
+
[ ] All
|
|
34
|
+
|
|
35
|
+
## Environment and Libraries (fill in the version numbers)
|
|
36
|
+
Cloudinary Ruby SDK version - 0.0.0
|
|
37
|
+
Ruby Version - 0.0.0
|
|
38
|
+
Rails Version - 0.0.0
|
|
39
|
+
Other Libraries (Carrierwave, ActiveStorage, etc) - 0.0.0
|
|
40
|
+
|
|
41
|
+
## Repository
|
|
42
|
+
If possible, please provide a link to a reproducible repository that showcases the problem
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature request
|
|
3
|
+
about: Feature request for Cloudinary Ruby SDK
|
|
4
|
+
title: ''
|
|
5
|
+
labels: ''
|
|
6
|
+
assignees: const-cloudinary
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Feature request for Cloudinary Ruby SDK
|
|
11
|
+
…(If your feature is for other SDKs, please request them there)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## Explain your use case
|
|
15
|
+
… (A high level explanation of why you need this feature)
|
|
16
|
+
|
|
17
|
+
## Describe the problem you’re trying to solve
|
|
18
|
+
… (A more technical view of what you’d like to accomplish, and how this feature will help you achieve it)
|
|
19
|
+
|
|
20
|
+
## Do you have a proposed solution?
|
|
21
|
+
… (yes, no? Please elaborate if needed)
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,65 @@
|
|
|
1
|
+
|
|
2
|
+
1.15.0 / 2020-06-11
|
|
3
|
+
===================
|
|
4
|
+
|
|
5
|
+
New functionality and features
|
|
6
|
+
------------------------------
|
|
7
|
+
|
|
8
|
+
* Add support for `accessibility_analysis` parameter
|
|
9
|
+
|
|
10
|
+
Other Changes
|
|
11
|
+
-------------
|
|
12
|
+
* Fix `download` function in `Cloudinary::CarrierWave`
|
|
13
|
+
* Fix handling of empty value in `if` parameter
|
|
14
|
+
* Fix consumption of configuration from environment variables
|
|
15
|
+
|
|
16
|
+
1.14.0 / 2020-05-06
|
|
17
|
+
===================
|
|
18
|
+
|
|
19
|
+
New functionality and features
|
|
20
|
+
------------------------------
|
|
21
|
+
|
|
22
|
+
* Add support of global folder in ActiveStorage
|
|
23
|
+
* Add duration to conditions in video
|
|
24
|
+
|
|
25
|
+
Other Changes
|
|
26
|
+
-------------
|
|
27
|
+
|
|
28
|
+
* Fix `URI.unescape is obsolete` warning
|
|
29
|
+
* Fix lingering Rails 6 autoload warnings
|
|
30
|
+
* Fix Ruby 1.9 CI build
|
|
31
|
+
* Allow setting uploader timeout to `nil`
|
|
32
|
+
* Update link to CarrierWave integration
|
|
33
|
+
* Update issue templates
|
|
34
|
+
|
|
35
|
+
1.13.2 / 2020-01-19
|
|
36
|
+
===================
|
|
37
|
+
|
|
38
|
+
* Fix asset extension detection in active storage service `url` method
|
|
39
|
+
|
|
40
|
+
1.13.1 / 2019-11-24
|
|
41
|
+
===================
|
|
42
|
+
|
|
43
|
+
* Remove `test_files` from `gemspec`
|
|
44
|
+
* Remove redundant binary files from `active_storage` spec
|
|
45
|
+
* Fix `rspec` deprecation warnings in Rails 6
|
|
46
|
+
* Add test for uploading IO
|
|
47
|
+
|
|
48
|
+
1.13.0 / 2019-11-14
|
|
49
|
+
===================
|
|
50
|
+
|
|
51
|
+
New functionality and features
|
|
52
|
+
------------------------------
|
|
53
|
+
* Add `SassC` `cloudinary-url` function
|
|
54
|
+
|
|
55
|
+
Other Changes
|
|
56
|
+
-------------
|
|
57
|
+
|
|
58
|
+
* Fix ActiveStorage download not using `ssl` for `https`
|
|
59
|
+
* Fix resource type detection in ActiveStorage
|
|
60
|
+
* Fix `storage_type` instance method in `Cloudinary::CarrierWave` module
|
|
61
|
+
* Fix sample project, limit sqlite3 to a compatible version
|
|
62
|
+
|
|
1
63
|
1.12.0 / 2019-10-02
|
|
2
64
|
=============
|
|
3
65
|
|
data/cloudinary.gemspec
CHANGED
|
@@ -15,8 +15,7 @@ Gem::Specification.new do |s|
|
|
|
15
15
|
|
|
16
16
|
s.rubyforge_project = "cloudinary"
|
|
17
17
|
|
|
18
|
-
s.files = (`git ls-files`.split("\n") - `git ls-files samples
|
|
19
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
18
|
+
s.files = (`git ls-files`.split("\n") - `git ls-files {test,spec,features,samples}/*`.split("\n")) + Dir.glob("vendor/assets/javascripts/*/*") + Dir.glob("vendor/assets/html/*")
|
|
20
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
21
20
|
s.require_paths = ["lib"]
|
|
22
21
|
|
|
@@ -25,11 +24,25 @@ Gem::Specification.new do |s|
|
|
|
25
24
|
|
|
26
25
|
s.add_development_dependency "actionpack"
|
|
27
26
|
s.add_development_dependency "nokogiri"
|
|
28
|
-
|
|
27
|
+
|
|
28
|
+
if RUBY_VERSION >= "2.2.0"
|
|
29
|
+
s.add_development_dependency "rake", ">= 13.0.1"
|
|
30
|
+
else
|
|
31
|
+
s.add_development_dependency "rake", "<= 12.2.1"
|
|
32
|
+
end
|
|
33
|
+
|
|
29
34
|
s.add_development_dependency "sqlite3"
|
|
30
35
|
s.add_development_dependency "rspec", '>=3.5'
|
|
31
36
|
s.add_development_dependency "rails", "~>5.2" if RUBY_VERSION >= "2.2.2"
|
|
37
|
+
|
|
38
|
+
s.add_development_dependency "railties", "<= 4.2.7" if RUBY_VERSION <= "1.9.3"
|
|
32
39
|
s.add_development_dependency "rspec-rails"
|
|
40
|
+
|
|
33
41
|
s.add_development_dependency "rubyzip", "<=1.2.0" # support testing Ruby 1.9
|
|
34
|
-
|
|
42
|
+
|
|
43
|
+
if RUBY_VERSION <= "2.4.0"
|
|
44
|
+
s.add_development_dependency "simplecov", "<= 0.17.1" # support testing Ruby 1.9
|
|
45
|
+
else
|
|
46
|
+
s.add_development_dependency "simplecov", "> 0.18.0"
|
|
47
|
+
end
|
|
35
48
|
end
|
|
@@ -12,6 +12,15 @@ unless ActiveStorage::Blob.method_defined? :original_key
|
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
+
module CloudinaryHelper
|
|
16
|
+
alias cloudinary_url_internal_original cloudinary_url_internal
|
|
17
|
+
|
|
18
|
+
def cloudinary_url_internal(source, options = {})
|
|
19
|
+
source = ActiveStorage::Blob.service.public_id(source) if defined? ActiveStorage::Blob.service.public_id
|
|
20
|
+
cloudinary_url_internal_original(source, options)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
15
24
|
module ActiveStorage
|
|
16
25
|
class Service::CloudinaryService < Service
|
|
17
26
|
module Headers
|
|
@@ -22,7 +31,6 @@ module ActiveStorage
|
|
|
22
31
|
|
|
23
32
|
def initialize(**options)
|
|
24
33
|
@options = options
|
|
25
|
-
@helper = ActionView::Base.new
|
|
26
34
|
end
|
|
27
35
|
|
|
28
36
|
def upload(key, io, filename: nil, checksum: nil, **options)
|
|
@@ -32,7 +40,7 @@ module ActiveStorage
|
|
|
32
40
|
options = @options.merge(options)
|
|
33
41
|
Cloudinary::Uploader.upload(
|
|
34
42
|
io,
|
|
35
|
-
public_id:
|
|
43
|
+
public_id: public_id_internal(key),
|
|
36
44
|
resource_type: resource_type(io, key),
|
|
37
45
|
context: {active_storage_key: key, checksum: checksum},
|
|
38
46
|
extra_headers: extra_headers,
|
|
@@ -49,9 +57,10 @@ module ActiveStorage
|
|
|
49
57
|
url = Cloudinary::Utils.cloudinary_url(
|
|
50
58
|
public_id(key),
|
|
51
59
|
resource_type: resource_type(nil, key),
|
|
52
|
-
format:
|
|
60
|
+
format: ext_for_file(filename, content_type),
|
|
53
61
|
**@options.merge(options.symbolize_keys)
|
|
54
62
|
)
|
|
63
|
+
|
|
55
64
|
payload[:url] = url
|
|
56
65
|
|
|
57
66
|
url
|
|
@@ -61,7 +70,7 @@ module ActiveStorage
|
|
|
61
70
|
def url_for_direct_upload(key, **options)
|
|
62
71
|
instrument :url, key: key do |payload|
|
|
63
72
|
options = {:resource_type => resource_type(nil, key)}.merge(@options.merge(options.symbolize_keys))
|
|
64
|
-
options[:public_id] =
|
|
73
|
+
options[:public_id] = public_id_internal(key)
|
|
65
74
|
options[:context] = {active_storage_key: key}
|
|
66
75
|
options.delete(:file)
|
|
67
76
|
payload[:url] = api_uri("upload", options)
|
|
@@ -102,12 +111,11 @@ module ActiveStorage
|
|
|
102
111
|
uri = URI(url)
|
|
103
112
|
if block_given?
|
|
104
113
|
instrument :streaming_download, key: key do
|
|
105
|
-
Net::HTTP.start(uri.host, uri.port) do |http|
|
|
114
|
+
Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
|
106
115
|
request = Net::HTTP::Get.new uri
|
|
107
116
|
http.request request do |response|
|
|
108
117
|
response.read_body &block
|
|
109
118
|
end
|
|
110
|
-
|
|
111
119
|
end
|
|
112
120
|
end
|
|
113
121
|
else
|
|
@@ -130,7 +138,7 @@ module ActiveStorage
|
|
|
130
138
|
else range.end
|
|
131
139
|
end
|
|
132
140
|
req['range'] = "bytes=#{[range.begin, range_end].join('-')}"
|
|
133
|
-
res = Net::HTTP.start(uri.hostname, uri.port) do |http|
|
|
141
|
+
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
|
134
142
|
http.request(req)
|
|
135
143
|
end
|
|
136
144
|
res.body.force_encoding(Encoding::BINARY)
|
|
@@ -138,20 +146,41 @@ module ActiveStorage
|
|
|
138
146
|
|
|
139
147
|
end
|
|
140
148
|
|
|
149
|
+
def public_id(key)
|
|
150
|
+
return key unless @options[:folder]
|
|
151
|
+
|
|
152
|
+
File.join(@options.fetch(:folder), public_id_internal(key))
|
|
153
|
+
end
|
|
154
|
+
|
|
141
155
|
private
|
|
142
156
|
|
|
143
157
|
def api_uri(action, options)
|
|
144
158
|
base_url = Cloudinary::Utils.cloudinary_api_url(action, options)
|
|
145
159
|
upload_params = Cloudinary::Uploader.build_upload_params(options)
|
|
146
160
|
|
|
147
|
-
upload_params.reject! {|k, v| Cloudinary::Utils.safe_blank?(v)}
|
|
161
|
+
upload_params.reject! { |k, v| Cloudinary::Utils.safe_blank?(v) }
|
|
148
162
|
unless options[:unsigned]
|
|
149
163
|
upload_params = Cloudinary::Utils.sign_request(upload_params, options)
|
|
150
164
|
end
|
|
151
165
|
"#{base_url}?#{upload_params.to_query}"
|
|
152
166
|
end
|
|
153
167
|
|
|
154
|
-
|
|
168
|
+
# Helper method for getting the filename extension.
|
|
169
|
+
#
|
|
170
|
+
# It does the best effort when original filename does not include extension, but we know the mime-type.
|
|
171
|
+
#
|
|
172
|
+
# @param [ActiveStorage::Filename] filename The original filename.
|
|
173
|
+
# @param [string] content_type The content type of the file.
|
|
174
|
+
#
|
|
175
|
+
# @return [string] The extension of the filename.
|
|
176
|
+
def ext_for_file(filename, content_type)
|
|
177
|
+
ext = filename.respond_to?(:extension_without_delimiter) ? filename.extension_without_delimiter : nil
|
|
178
|
+
return ext unless ext.blank?
|
|
179
|
+
|
|
180
|
+
# Raw files are not convertible, no extension guessing for them
|
|
181
|
+
return nil if content_type_to_resource_type(content_type).eql?('raw')
|
|
182
|
+
|
|
183
|
+
# Fallback when there is no extension.
|
|
155
184
|
@formats ||= Hash.new do |h, key|
|
|
156
185
|
ext = Rack::Mime::MIME_TYPES.invert[key]
|
|
157
186
|
h[key] = ext.slice(1..-1) unless ext.nil?
|
|
@@ -159,23 +188,36 @@ module ActiveStorage
|
|
|
159
188
|
@formats[content_type]
|
|
160
189
|
end
|
|
161
190
|
|
|
162
|
-
def
|
|
191
|
+
def public_id_internal(key)
|
|
163
192
|
# TODO: Allow custom manipulation of key to obscure how we store in Cloudinary
|
|
164
193
|
key
|
|
165
194
|
end
|
|
166
195
|
|
|
167
|
-
def
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
case content_type.split('/')[0]
|
|
172
|
-
when 'video'
|
|
196
|
+
def content_type_to_resource_type(content_type)
|
|
197
|
+
type, subtype = content_type.split('/')
|
|
198
|
+
case type
|
|
199
|
+
when 'video', 'audio'
|
|
173
200
|
'video'
|
|
174
201
|
when 'text'
|
|
175
202
|
'raw'
|
|
203
|
+
when 'application'
|
|
204
|
+
case subtype
|
|
205
|
+
when 'pdf', 'postscript'
|
|
206
|
+
'image'
|
|
207
|
+
when 'vnd.apple.mpegurl', 'x-mpegurl', 'mpegurl' # m3u8
|
|
208
|
+
'video'
|
|
209
|
+
else
|
|
210
|
+
'raw'
|
|
211
|
+
end
|
|
176
212
|
else
|
|
177
213
|
'image'
|
|
178
214
|
end
|
|
179
215
|
end
|
|
216
|
+
|
|
217
|
+
def resource_type(io, key = "")
|
|
218
|
+
options = key.respond_to?(:attributes) ? key.attributes : {}
|
|
219
|
+
content_type = options[:content_type] || (io.nil? ? '' : Marcel::MimeType.for(io))
|
|
220
|
+
content_type_to_resource_type(content_type)
|
|
221
|
+
end
|
|
180
222
|
end
|
|
181
223
|
end
|
data/lib/cloudinary.rb
CHANGED
|
@@ -64,19 +64,7 @@ module Cloudinary
|
|
|
64
64
|
first_time = @@config.nil?
|
|
65
65
|
@@config ||= OpenStruct.new((YAML.load(ERB.new(IO.read(config_dir.join("cloudinary.yml"))).result)[config_env] rescue {}))
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
if first_time && ENV["CLOUDINARY_CLOUD_NAME"]
|
|
69
|
-
set_config(
|
|
70
|
-
"cloud_name" => ENV["CLOUDINARY_CLOUD_NAME"],
|
|
71
|
-
"api_key" => ENV["CLOUDINARY_API_KEY"],
|
|
72
|
-
"api_secret" => ENV["CLOUDINARY_API_SECRET"],
|
|
73
|
-
"secure_distribution" => ENV["CLOUDINARY_SECURE_DISTRIBUTION"],
|
|
74
|
-
"private_cdn" => ENV["CLOUDINARY_PRIVATE_CDN"].to_s == 'true',
|
|
75
|
-
"secure" => ENV["CLOUDINARY_SECURE"].to_s == 'true'
|
|
76
|
-
)
|
|
77
|
-
elsif first_time && ENV["CLOUDINARY_URL"]
|
|
78
|
-
config_from_url(ENV["CLOUDINARY_URL"])
|
|
79
|
-
end
|
|
67
|
+
config_from_env if first_time
|
|
80
68
|
|
|
81
69
|
set_config(new_config) if new_config
|
|
82
70
|
yield(@@config) if block_given?
|
|
@@ -105,7 +93,7 @@ module Cloudinary
|
|
|
105
93
|
if isNestedKey? key
|
|
106
94
|
putNestedKey key, value
|
|
107
95
|
else
|
|
108
|
-
set_config(key =>
|
|
96
|
+
set_config(key => Utils.smart_unescape(value))
|
|
109
97
|
end
|
|
110
98
|
end
|
|
111
99
|
end
|
|
@@ -140,18 +128,34 @@ module Cloudinary
|
|
|
140
128
|
end
|
|
141
129
|
|
|
142
130
|
private
|
|
143
|
-
|
|
131
|
+
|
|
132
|
+
def self.config_from_env
|
|
133
|
+
# Heroku support
|
|
134
|
+
if ENV["CLOUDINARY_CLOUD_NAME"]
|
|
135
|
+
config_keys = ENV.keys.select! { |key| key.start_with? "CLOUDINARY_" }
|
|
136
|
+
config_keys -= ["CLOUDINARY_URL"] # ignore it when explicit options are passed
|
|
137
|
+
config_keys.each do |full_key|
|
|
138
|
+
conf_key = full_key["CLOUDINARY_".length..-1].downcase # convert "CLOUDINARY_CONFIG_NAME" to "config_name"
|
|
139
|
+
conf_val = ENV[full_key]
|
|
140
|
+
conf_val = conf_val == 'true' if %w[true false].include?(conf_val) # cast relevant boolean values
|
|
141
|
+
set_config(conf_key => conf_val)
|
|
142
|
+
end
|
|
143
|
+
elsif ENV["CLOUDINARY_URL"]
|
|
144
|
+
config_from_url(ENV["CLOUDINARY_URL"])
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
144
148
|
def self.config_env
|
|
145
149
|
return ENV["CLOUDINARY_ENV"] if ENV["CLOUDINARY_ENV"]
|
|
146
150
|
return Rails.env if defined? Rails::env
|
|
147
151
|
nil
|
|
148
152
|
end
|
|
149
|
-
|
|
153
|
+
|
|
150
154
|
def self.config_dir
|
|
151
|
-
return Pathname.new(ENV["CLOUDINARY_CONFIG_DIR"]) if ENV["CLOUDINARY_CONFIG_DIR"]
|
|
155
|
+
return Pathname.new(ENV["CLOUDINARY_CONFIG_DIR"]) if ENV["CLOUDINARY_CONFIG_DIR"]
|
|
152
156
|
self.app_root.join("config")
|
|
153
157
|
end
|
|
154
|
-
|
|
158
|
+
|
|
155
159
|
def self.set_config(new_config)
|
|
156
160
|
new_config.each{|k,v| @@config.send(:"#{k}=", v) if !v.nil?}
|
|
157
161
|
end
|
data/lib/cloudinary/api.rb
CHANGED
|
@@ -78,7 +78,7 @@ class Cloudinary::Api
|
|
|
78
78
|
resource_type = options[:resource_type] || "image"
|
|
79
79
|
type = options[:type] || "upload"
|
|
80
80
|
uri = "resources/#{resource_type}/#{type}/#{public_id}"
|
|
81
|
-
call_api(:get, uri,
|
|
81
|
+
call_api(:get, uri,
|
|
82
82
|
only(options,
|
|
83
83
|
:cinemagraph_analysis,
|
|
84
84
|
:colors,
|
|
@@ -90,7 +90,8 @@ class Cloudinary::Api
|
|
|
90
90
|
:pages,
|
|
91
91
|
:phash,
|
|
92
92
|
:quality_analysis,
|
|
93
|
-
:derived_next_cursor
|
|
93
|
+
:derived_next_cursor,
|
|
94
|
+
:accessibility_analysis
|
|
94
95
|
), options)
|
|
95
96
|
end
|
|
96
97
|
|
|
@@ -10,7 +10,8 @@ module Cloudinary::CarrierWave
|
|
|
10
10
|
def self.included(base)
|
|
11
11
|
base.storage Cloudinary::CarrierWave::Storage
|
|
12
12
|
base.extend ClassMethods
|
|
13
|
-
base.class_attribute :
|
|
13
|
+
base.class_attribute :metadata
|
|
14
|
+
base.class_attribute :storage_type, instance_reader: false
|
|
14
15
|
override_in_versions(base, :blank?, :full_public_id, :my_public_id, :all_versions_processors, :stored_version)
|
|
15
16
|
end
|
|
16
17
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
module Cloudinary::CarrierWave
|
|
2
2
|
def download!(uri, *args)
|
|
3
|
-
return super
|
|
3
|
+
return super unless self.cloudinary_should_handle_remote?
|
|
4
4
|
if respond_to?(:process_uri)
|
|
5
5
|
uri = process_uri(uri)
|
|
6
6
|
else # Backward compatibility with old CarrierWave
|
|
7
|
-
uri = URI.parse(
|
|
7
|
+
uri = URI.parse(Cloudinary::Utils.smart_escape(Cloudinary::Utils.smart_unescape(uri)))
|
|
8
8
|
end
|
|
9
9
|
return if uri.to_s.blank?
|
|
10
10
|
self.original_filename = @cache_id = @filename = File.basename(uri.path).gsub(/[^a-zA-Z0-9\.\-\+_]/, '')
|