當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。