当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript needle.put函数代码示例

本文整理汇总了TypeScript中needle.put函数的典型用法代码示例。如果您正苦于以下问题:TypeScript put函数的具体用法?TypeScript put怎么用?TypeScript put使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了put函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: API_put

function API_put() {
    var nested = {
        params: {
            are: {
                also: 'supported'
            }
        }
    };

    needle.put('https://api.app.com/v2', nested, function (err, resp) {
        console.log('Got ' + resp.bytes + ' bytes.') // another nice treat from this handsome fella.
    });
}
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:13,代码来源:needle-tests.ts

示例2: FileUpload

function FileUpload() {
    var data = {
        foo: 'bar',
        image: { file: '/home/tomas/linux.png', content_type: 'image/png' }
    };

    needle.post('http://my.other.app.com', data, { multipart: true }, function(err, resp, body) {
        // needle will read the file and include it in the form-data as binary
    });
    needle.put('https://api.app.com/v2', fs.createReadStream('myfile.txt'), function(err, resp, body) {
        // stream content is uploaded verbatim
    });
}
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:13,代码来源:needle-tests.ts

示例3: API_put

function API_put() {
    const nested = {
        params: {
            are: {
                also: 'supported'
            }
        }
    };

    // using promises
    needle('put', 'https://api.app.com/v2', nested)
        .then((resp) => {
            console.log(`Got ${resp.bytes} bytes.`); // another nice treat from this handsome fella.
        });

    // using callback
    needle.put('https://api.app.com/v2', nested, (err, resp) => {
        console.log(`Got ${resp.bytes} bytes.`); // another nice treat from this handsome fella.
    });
}
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:20,代码来源:needle-tests.ts

示例4: FileUpload

function FileUpload() {
    const data = {
        foo: 'bar',
        image: { file: '/home/tomas/linux.png', content_type: 'image/png' }
    };

    // using promises
    needle('post', 'http://my.other.app.com', data, { multipart: true })
        .then((resp) => {
            // needle will read the file and include it in the form-data as binary
        });
    needle('put', 'https://api.app.com/v2', fs.createReadStream('myfile.txt'))
        .then((resp) => {
            // stream content is uploaded verbatim
        });

    // using callback
    needle.post('http://my.other.app.com', data, { multipart: true }, (err, resp, body) => {
        // needle will read the file and include it in the form-data as binary
    });
    needle.put('https://api.app.com/v2', fs.createReadStream('myfile.txt'), (err, resp, body) => {
        // stream content is uploaded verbatim
    });
}
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:24,代码来源:needle-tests.ts


注:本文中的needle.put函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。