Api 到 return azure blob 存储数据

Api to return azure blob storage data

我有一个 Node.js API 应用程序。该计划适用于通往 return 天蓝色 blob 内容的特定路线。

所以在我的处理程序中,我有以下代码:

'use strict';
var dataProvider = require('../../data/ControlAPI/ListControls.js');
/**
 * Operations on /ControlAPI/ListControls
 */
module.exports = {
    /**
     * summary: 
     * description: 
     * parameters: 
     * produces: application/json, text/json
     * responses: 200
     */
    get: function controlapi_listcontrol(req, res, next) {
        /**
         * Get the data for response 200
         * For response `default` status 200 is used.
         */
        var status = 200;
        var provider = dataProvider['get']['200'];
        provider(req, res, function (err, data) {
            if (err) {
                next(err);
                return;
            }
            // res.status(status).send(data && data.responses);
            var azure = require('azure-storage');
            var blobsrv = azure.createBlobService(
                'accname',
                'key'
                )

            var tools = ""; 
            blobsrv.getBlobToText('tools', 'toolbox.json ', tools, function (error, res) {})
            res.json = tools;
        });
    }
};

我假设我在这里做了一些愚蠢的事情,但是当我调用我的 API 路由时,我从未得到响应(甚至没有错误)。

有谁知道为什么它不提供任何类型的 error/success 代码?

你需要在回调函数中加入res.json = tools;

同平Node.js:

blobsrv.getBlobToText('tools', 'toolbox.json', function (error, text) {

    res.setHeader('Content-Type', 'application/json');
    res.send(text);
})

有快递:

blobsrv.getBlobToText('tools', 'toolbox.json', function (error, text) {

    res.json(text);
})