Skip to content

Commit 04dcd41

Browse files
nadavofirtocker
authored andcommitted
add support for URLs in upload_large
1 parent 20b0231 commit 04dcd41

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/uploader.coffee

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ exports.upload = (file, callback, options = {}) ->
3636
[params, {}, file]
3737

3838
exports.upload_large = (path, callback, options = {}) ->
39-
exports.upload_chunked(path, callback, _.extend({resource_type: 'raw'}, options))
39+
if path? && path.match(/^https?:/)
40+
exports.upload(path, callback, options)
41+
else
42+
exports.upload_chunked(path, callback, _.extend({resource_type: 'raw'}, options))
4043

4144
exports.upload_chunked = (path, callback, options) ->
4245
file_reader = fs.createReadStream(path)

test/uploader_spec.coffee

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,14 @@ describe "uploader", ->
478478
done()
479479
true
480480
true
481+
482+
it "should support uploading based on a url", (done) ->
483+
@timeout helper.TIMEOUT_MEDIUM
484+
cloudinary.v2.uploader.upload_large "http://cloudinary.com/images/old_logo.png", {tags: UPLOAD_TAGS}, (error, result) ->
485+
return done(new Error error.message) if error?
486+
expect(result.etag).to.eql("7dc60722d4653261648038b579fdb89e")
487+
done()
488+
true
481489

482490
it "should support unsigned uploading using presets", (done) ->
483491
@timeout helper.TIMEOUT_LONG

0 commit comments

Comments
 (0)