Skip to content

Commit be40fe6

Browse files
author
Amir Tocker
committed
Add remove_all_tags API
1 parent 3b19f50 commit be40fe6

File tree

7 files changed

+39
-15
lines changed

7 files changed

+39
-15
lines changed

lib/uploader.js

Lines changed: 21 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/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.

lib/v2/uploader.js

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

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.

src/uploader.coffee

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,18 +175,23 @@ exports.add_tag = (tag, public_ids = [], callback, options = {}) ->
175175
exports.remove_tag = (tag, public_ids = [], callback, options = {}) ->
176176
call_tags_api(tag, "remove", public_ids, callback, options)
177177

178+
exports.remove_all_tags = (public_ids = [], callback, options = {}) ->
179+
call_tags_api(null, "remove_all", public_ids, callback, options)
180+
178181
exports.replace_tag = (tag, public_ids = [], callback, options = {}) ->
179182
call_tags_api(tag, "replace", public_ids, callback, options)
180183

181184
call_tags_api = (tag, command, public_ids = [], callback, options = {}) ->
182185
call_api "tags", callback, options, ->
183-
return [{
186+
params = {
184187
timestamp: utils.timestamp(),
185-
tag: tag,
186188
public_ids: utils.build_array(public_ids),
187189
command: command,
188190
type: options.type
189-
}]
191+
}
192+
if tag?
193+
params.tag = tag
194+
return [params]
190195

191196
call_api = (action, callback, options, get_params) ->
192197
deferred = Q.defer()

src/v2/uploader.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ utils.v1_adapters exports, uploader,
1919
explode: 1,
2020
add_tag: 2,
2121
remove_tag: 2,
22+
remove_all_tags: 1,
2223
replace_tag: 2,
2324
create_archive: 0,
2425
create_zip: 0

test/uploader_spec.coffee

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,12 @@ describe "uploader", ->
185185
cloudinary.v2.api.resource second_id, (error, r1) ->
186186
return done(new Error error.message) if error
187187
expect(r1.tags).to.contain("tag1")
188-
done()
188+
cloudinary.v2.uploader.remove_all_tags [first_id, second_id, 'noSuchId'], (err, res)->
189+
expect(res["public_ids"]).to.contain(first_id)
190+
expect(res["public_ids"]).to.contain(second_id)
191+
expect(res["public_ids"]).to.not.contain('noSuchId')
192+
cloudinary.v2.api.delete_resources [first_id, second_id], (err, res)->
193+
done()
189194

190195
it "should keep existing tags when adding a new tag", (done)->
191196
upload_image (result1)->

0 commit comments

Comments
 (0)