index.js
function (url, options, callback) {
            var args = arguments,
                r,
                handler,
                params,
                data = '',
                retry = false,
                requestOptions = {
                    method: 'POST',
                    headers: {
                        'content-type': 'application/json'
                    }
                };

            if (typeof options === 'function') {
                callback = options;
                params = {};
            } else {
                options = extend({}, options);
                params = extend({}, options.params);
                retry = options.retry;
            }

            retry = (retry === true) && function () {
                this.uploadURL.apply(this, args);
            }.bind(this);

            if (!params.name) {
                params.name = path.basename(url);
            }

            params.url = url;

            handler = createResponseHandler(callback, [200, 202], retry);

            r = req(client.documentsURL, requestOptions, handler);

            data = new Buffer(JSON.stringify(params));
            r.setHeader('content-length', data.length);
            r.end(data);
            return r;
        }
function (url, options, callback) {
            var args = arguments,
                r,
                handler,
                params,
                data = '',
                retry = false,
                requestOptions = {
                    method: 'POST',
                    headers: {
                        'content-type': 'application/json'
                    }
                };

            if (typeof options === 'function') {
                callback = options;
                params = {};
            } else {
                options = extend({}, options);
                params = extend({}, options.params);
                retry = options.retry;
            }

            retry = (retry === true) && function () {
                this.uploadURL.apply(this, args);
            }.bind(this);

            if (!params.name) {
                params.name = path.basename(url);
            }

            params.url = url;

            handler = createResponseHandler(callback, [200, 202], retry);

            r = req(client.documentsURL, requestOptions, handler);

            data = new Buffer(JSON.stringify(params));
            r.setHeader('content-length', data.length);
            r.end(data);
            return r;
        }
function ( url , options , callback ) { var args = arguments , r , handler , params , data = '' , retry = false , requestOptions = { method : 'POST' , headers : { 'content-type' : 'application/json' } } ; if ( typeof options === 'function' ) { callback = options ; params = { } ; } else { options = extend ( { } , options ) ; params = extend ( { } , options . params ) ; retry = options . retry ; } retry = ( retry === true ) && function ( ) { this . uploadURL . apply ( this , args ) ; } . bind ( this ) ; if ( ! params . name ) { params . name = path . basename ( url ) ; } params . url = url ; handler = createResponseHandler ( callback , [ 200 , 202 ] , retry ) ; r = req ( client . documentsURL , requestOptions , handler ) ; data = new Buffer ( JSON . stringify ( params ) ) ; r . setHeader ( 'content-length' , data . length ) ; r . end ( data ) ; return r ; }
Do a URL upload of a file
@param   {String}   url                         A URL to a publicly-accessible file to upload
@param   {Object}   [options]                   Upload options
@param   {boolean}  [options.retry]             Whether to retry the request after 'retry-after' seconds if the retry-after header is sent
@param   {Object}   [options.params]            Upload parameters
@param   {String}   [options.params.name]       The name of the file
@param   {String}   [options.params.thumbnails] Comma-separated list of thumbnail dimensions of the format {width}x{height} e.g. 128×128,256×256 – width can be between 16 and 1024, height between 16 and 768
@param   {Boolean}  [options.params.non_svg]    Whether to also create the non-svg version of the document
@param   {Function} [callback]                  A callback to call with the response data (or error)
@returns {Request}
Do a URL upload of a file