none
[Node.js][Azure Storage] Can't upload to azure blob using createBlockBlobFromLocalFile() RRS feed

  • Question

  • Hello azure community Im a total newbie on using azure so I wanted to ask this problem that's been bothering me for a few days now. I cant upload to my azure blob container using the following code in node/express backend.

    Here's what i've done so far.

    1. I can upload successfully the file from front end to the server which creates a copy of the image in a directory on the server.
    2. I can locate the image from the right path.

    var blobSvc = azure.createBlobService(config.BLOB_ACCOUNT, config.BLOB_KEY);
    
    controllers.upload = function (req, res, next){
    
        req.pipe(req.busboy);
        var fstream;
    
        req.busboy.on('file', function (fieldname, file, filename) {
    
            fstream = fs.createWriteStream(__dirname + '/upload/' + filename);
            file.pipe(fstream);
    
            fstream.on('close', function () {
                blobSvc.createBlockBlobFromLocalFile('resources',
                        filename,
                        fstream.path,
                        function(error, result, response) {
                            if (error) {
                                res.send(error);
                                return;
                            }
                            res.send(result);
                        });
            });
        });
    }

    Even so, Im still having this error and I am aware that the filename of the image should be DNS acceptable, to simple the process I tried to just upload an image named `ragnar.jpg`, it was successfully upload to the my server and the file path was right. 

    The errror :

    {code: "OutOfRangeInput", statusCode: 400, requestId: "00d83e3f-0001-002f-2c40-8cf7a5000000"}

    Am i missing something? 

    Few questions : 

    1. Did I do the right process to upload the image to a directory on my server and use the `createBlockBlobFromLocalFile()` function?

    2. I did not create a SAS Token, for this process. Is that ok?

    3. In the response headers the content-type is "application/xml" does that affect the process?

    Thank you in advance people. :)




    Saturday, April 2, 2016 2:59 AM

Answers

All replies