none
[Node.js][Azure Storage] Azure Upload states as successful (POST 200 OK), but no file uploaded actually to container RRS feed

  • Question

  • Hi all,

    I am using the following to upload from an AngularJS front end form to Azure Blob Storage via Node/Multiparty. It returns a POST 200 OK with the type of document, however, when I check my Azure Blob Storage with a tool such as Azure Storage Explorer, the file is no where to be found.

    Here is my form in the AngularJS view:

    <form action="/upload2" method="post" enctype="multipart/form-data">
        <input type="file" name="myfile" />
        <input type="submit" value="Upload" />
    </form>

    Here is my server.js

    var express = require('express');
    var azure = require('azure-storage');
    // A node.js module for parsing multipart-form data requests which supports streams2    https://github.com/andrewrk/node-multiparty
    var multiparty = require('multiparty');
    
    // Initialize Express App
    var app = express();
    var port = process.env.port || 1337;
    app.use(express.static(__dirname + "/public")).listen(port);
    
    var accessKey = 'mykey';
    var storageAccount = 'myblob';
    
    var blobSvc = azure.createBlobService(storageAccount, accessKey);
    
    app.post('/upload2', function (req, res) {
    
    var form = new multiparty.Form();
    
    form.on('part', function (part) {
        if (!part.filename) return;
    
        var size = part.byteCount;
        var name = part.filename;
        var container = 'mycontainer';
    
        blobSvc.createBlockBlobFromStream(container, name, part, size, function (error) {
            if (error) {
                    //res.send(' Blob create: error ');
            }
        });
    });
    form.parse(req);
    res.send('File uploaded successfully');
    });


    Personal Blog: http://thebitsthatbyte.com



    Tuesday, September 15, 2015 1:24 AM

Answers

  • Hi Kelly,

    I suggest you to refer the below article which is very similar to your query.

    http://stackoverflow.com/questions/32569078/node-js-upload-to-azure-blob-storage-issues

    http://www.jonahnisenson.com/file-uploads-using-angular-and-nodeexpress/

    Let us know if this helps you.

    Girish Prajwal

    Disclaimer: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.  


    • Edited by Girish Prajwal Wednesday, September 16, 2015 6:57 PM
    • Marked as answer by Kelly Rusk Wednesday, September 16, 2015 8:48 PM
    Wednesday, September 16, 2015 6:53 PM

All replies

  • Hi Kelly,

    I suggest you to refer the below article which is very similar to your query.

    http://stackoverflow.com/questions/32569078/node-js-upload-to-azure-blob-storage-issues

    http://www.jonahnisenson.com/file-uploads-using-angular-and-nodeexpress/

    Let us know if this helps you.

    Girish Prajwal

    Disclaimer: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.  


    • Edited by Girish Prajwal Wednesday, September 16, 2015 6:57 PM
    • Marked as answer by Kelly Rusk Wednesday, September 16, 2015 8:48 PM
    Wednesday, September 16, 2015 6:53 PM
  • Thanks Girish, that was actually my post on Stack Overflow. I forgot to post my answer back here that I needed to use require Azure and not require Azure-storage.

    Personal Blog: http://thebitsthatbyte.com

    Wednesday, September 16, 2015 8:48 PM