Skip to content

Commit 4683ff2

Browse files
author
Amir Tocker
committed
Merge branch 'master' into feature/search-by-context
# Conflicts: # lib/api.js # lib/api.js.map # lib/config.js # lib/preloaded_file.js # lib/upload_stream.js # lib/uploader.js # lib/uploader.js.map # lib/utils.js # lib/utils.js.map # lib/v2/api.js # lib/v2/index.js # lib/v2/uploader.js # test/api_spec.coffee
2 parents 946be7c + fefa663 commit 4683ff2

15 files changed

+244
-84
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
language: node_js
22
node_js:
3-
- '5.11'
3+
- '4'
4+
- '6'
45
env:
56
matrix:
67
secure: JXtnVGwM09h0TwTD3pl4htaVn0fotnbfXNvFUXKnz/+OOETha5/GtaZSzrKTWUBbLAlC1VfE9FN5YovKOnfknquijBlgZi+lc3AX7r/chtvSGJiSqGtvQwtmOsNrF/eUIZ1rmoZSGbPgwSB7/3Mg8yyrx402d9dripiAYugAPJuOnhMUa2JlR2nQqBEJf90yeqIO9luKBeBUJCYUxSJeJhSAUgSRoPq8Z7OOtIePTShtN3cwFD/X2+OsTrQc99qqQQH1iC8DPQZgWjIjDwuzzDovy16gVanto+X2Mbb8pxsFu0LkPz0z25W/MBpU+Wyobmb8mcyvgo0Wjbcrf2u0OzOtpDF04TyjBQroLi/7gwlFGro1IIEkNVgF9Ju7LepFKrChS3fe9Wk7a/cey//PkC/A5I8hHr8Ii06Ew7oAnLsgDs6Ib6QN4kOWvVCoQ1rDVGiqaNH8WtET+l2EpBFXocxdPMTKVd4x/oQSUbripiDpsYKS+FLSiZ91sqDh2wF6jxdaTNOwB3/5RN+2HF3d1nFWtwiglXsTaP9ojJGFus518tT9oi5rkz6fUE7A8HleLX5ezziHOW8XQ4Ui/3dYyn52lVpN3ZVeZrh4PtVviYzf9tuVXvh8TwMPZHTOIIYVj3RYERflCJeb7CgPRd5fO/uwrD7IZFeZ1ScMBkCY+aU=

CHANGELOG.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,35 @@
11

2+
1.5.0 / 2016-12-29
3+
==================
4+
5+
New functionality
6+
-----------------
7+
8+
* `add_context` & `remove_all_context` API
9+
* Add `data-max-chunk-size` to input created by `image_upload_tag`
10+
* Add `moderation` and `phash` parameters to explicit API
11+
12+
13+
Other changes
14+
-------------
15+
16+
* Modify Travis configuration to test NodeJS v4 and v6 only.
17+
* Modify `TEST_TAG`
18+
* Use Sinon spy in `start_at` test
19+
* Support context as hash argument in context API
20+
* Delete streaming profiles after tests
21+
* Fix signing URL tests, Fixes #89
22+
* Add timeout to delete streaming profile test
23+
* add tests for add_context & remove_all_context
24+
* add add_context & remove_all_context methods
25+
* fix test description
26+
* add test to phash in an explicit call
27+
* add test to moderation parameter in an explicit call
28+
* Add test to accepts {effect: art:incognito}
29+
* support phash in explicit call
30+
* Fix missing moderation parameter in an explicit call
31+
* Fix `nil` to `null`. Call `config()` with parameter name.
32+
233
1.4.6 / 2016-11-25
334
==================
435

lib/v2/uploader.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"author": "Cloudinary <[email protected]>",
33
"name": "cloudinary",
44
"description": "Cloudinary NPM for node.js integration",
5-
"version": "1.4.6",
5+
"version": "1.5.0",
66
"homepage": "http://cloudinary.com",
77
"license": "MIT",
88
"repository": {
@@ -18,14 +18,17 @@
1818
"coffee-script": "^1.10.0",
1919
"dotenv": "1.x",
2020
"expect.js": "0.3.x",
21+
"jsdom": "^9.5.0",
22+
"jsdom-global": "^2.1.0",
2123
"mocha": "2.3.x",
2224
"sinon": "^1.17.2"
2325
},
2426
"scripts": {
2527
"pretest": "npm run compile",
2628
"prepublish": "npm run compile",
2729
"test": "node_modules/.bin/mocha -R spec --recursive test/",
28-
"compile": "node_modules/.bin/coffee --map -o lib -c src"
30+
"compile": "node_modules/.bin/coffee --map -o lib -c src",
31+
"watch": "node_modules/.bin/coffee --watch --map -o lib -c src"
2932
},
3033
"optionalDependencies": {},
3134
"engines": {

src/api.coffee

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ api = module.exports
1212

1313
call_api = (method, uri, params, callback, options) ->
1414
deferred = Q.defer()
15-
cloudinary = options["upload_prefix"] ? config().upload_prefix ? "https://api.cloudinary.com"
16-
cloud_name = options["cloud_name"] ? config().cloud_name ? throw("Must supply cloud_name")
17-
api_key = options["api_key"] ? config().api_key ? throw("Must supply api_key")
18-
api_secret = options["api_secret"] ? config().api_secret ? throw("Must supply api_secret")
15+
cloudinary = options["upload_prefix"] ? config("upload_prefix") ? "https://api.cloudinary.com"
16+
cloud_name = options["cloud_name"] ? config("cloud_name") ? throw("Must supply cloud_name")
17+
api_key = options["api_key"] ? config("api_key") ? throw("Must supply api_key")
18+
api_secret = options["api_secret"] ? config("api_secret") ? throw("Must supply api_secret")
1919
api_url = [cloudinary, "v1_1", cloud_name].concat(uri).join("/")
2020
query_params = querystring.stringify(params)
2121
if method == "get"
@@ -233,7 +233,7 @@ exports.upload_mappings = (callback, options = {})->
233233
params = api.only(options, "next_cursor", "max_results")
234234
call_api("get", "upload_mappings", params, callback, options)
235235

236-
exports.upload_mapping = (name = nil, callback, options = {})->
236+
exports.upload_mapping = (name = null, callback, options = {})->
237237
call_api("get", 'upload_mappings', {folder: name}, callback, options)
238238

239239
exports.delete_upload_mapping = (name, callback, options = {})->

src/uploader.coffee

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,24 @@ call_tags_api = (tag, command, public_ids = [], callback, options = {}) ->
196196
params.tag = tag
197197
return [params]
198198

199+
exports.add_context = (context, public_ids = [], callback, options = {}) ->
200+
call_context_api(context, 'add', public_ids, callback, options)
201+
202+
exports.remove_all_context = (public_ids = [], callback, options = {}) ->
203+
call_context_api(null, 'remove_all', public_ids, callback, options)
204+
205+
call_context_api = (context, command, public_ids = [], callback, options = {}) ->
206+
call_api 'context', callback, options, ->
207+
params = {
208+
timestamp: utils.timestamp(),
209+
public_ids: utils.build_array(public_ids),
210+
command: command,
211+
type: options.type
212+
}
213+
if context?
214+
params.context = utils.encode_key_value(context)
215+
return [params]
216+
199217
call_api = (action, callback, options, get_params) ->
200218
deferred = Q.defer()
201219
options ?= {}
@@ -340,6 +358,7 @@ exports.image_upload_tag = (field, options = {}) ->
340358
"data-url": exports.upload_url(options),
341359
"data-form-data": exports.upload_tag_params(options),
342360
"data-cloudinary-field": field,
361+
"data-max-chunk-size": options.chunk_size,
343362
"class": [html_options["class"], "cloudinary-fileupload"].join(" ")
344363
}, html_options)
345364
return '<input ' + utils.html_attrs(tag_options) + '/>'

src/utils.coffee

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ exports.url = (public_id, options = {}) ->
417417
if sign_url
418418
to_sign = [transformation, source_to_sign].filter((part) -> part? && part != '').join('/')
419419
shasum = crypto.createHash('sha1')
420-
shasum.update(utf8_encode(to_sign + api_secret))
420+
shasum.update(utf8_encode(to_sign + api_secret), 'binary')
421421
signature = shasum.digest('base64').replace(/\//g, '_').replace(/\+/g, '-').substring(0, 8)
422422
signature = "s--#{signature}--"
423423

@@ -597,7 +597,7 @@ exports.signed_preloaded_image = (result) ->
597597
exports.api_sign_request = (params_to_sign, api_secret) ->
598598
to_sign = _.sortBy("#{k}=#{utils.build_array(v).join(",")}" for k, v of params_to_sign when v?, _.identity).join("&")
599599
shasum = crypto.createHash('sha1')
600-
shasum.update(utf8_encode(to_sign + api_secret))
600+
shasum.update(utf8_encode(to_sign + api_secret), 'binary')
601601
shasum.digest('hex')
602602

603603
exports.clear_blank = (hash) ->
@@ -626,7 +626,7 @@ exports.webhook_signature = (data, timestamp, options = {}) ->
626626
throw "Must supply timestamp" unless timestamp
627627
api_secret = options.api_secret ? config().api_secret ? throw("Must supply api_secret")
628628
shasum = crypto.createHash('sha1')
629-
shasum.update(data + timestamp + api_secret)
629+
shasum.update(data + timestamp + api_secret, 'binary')
630630
shasum.digest('hex')
631631

632632
exports.process_request_params = (params, options) ->
@@ -847,6 +847,8 @@ exports.build_explicit_api_params = (public_id, options = {})->
847847
face_coordinates: options.face_coordinates && utils.encode_double_array(options.face_coordinates)
848848
headers: build_custom_headers(options.headers)
849849
invalidate: utils.as_safe_bool(options.invalidate)
850+
moderation: options.moderation
851+
phash: utils.as_safe_bool(options.phash)
850852
public_id: public_id
851853
responsive_breakpoints: utils.generate_responsive_breakpoints_string(options.responsive_breakpoints)
852854
tags: options.tags && utils.build_array(options.tags).join(",")

src/v2/uploader.coffee

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ utils.v1_adapters exports, uploader,
2020
add_tag: 2,
2121
remove_tag: 2,
2222
remove_all_tags: 1,
23+
add_context: 2,
24+
remove_all_context: 1,
2325
replace_tag: 2,
2426
create_archive: 0,
2527
create_zip: 0

0 commit comments

Comments
 (0)