Monday, 13 March 2017

Api to return azure blob storage data

I have a Node.js API App. The plan is for this particular route to return the content of an azure blob.

So in my handler, I have the following code:

'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(
                'container',
                'key'
                )

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

I assume I have done something silly here but when I call my API route, I never get a response (not even an error).

Does anyone know why it isn't giving any sort of error/success code?



via Andrew Berry

No comments:

Post a Comment