pillarjs/multiparty

Azure Example - is the success callback in the right place?

graham-sportsmgmt opened this issue · 3 comments

This is probably an issue with either the example or the documentation. I'm happy to work on either to clarify this once someone provides guidance.

The example for Azure Blob Storage sends a success response after form.parse(req) (on line 37):

      blobService.createBlockBlobFromStream(container, name, part, size, function(error) {
        if (error) {
          // error handling
        }
      });
    });

    form.parse(req);

    res.send('File uploaded successfully');

By normal node.js callback standards, should this success response not be inside the createBlockBlobFromStream callback as follows?

      blobService.createBlockBlobFromStream(container, name, part, size, function(error) {
        if (error) {
          // error handling
        }
        res.send('File uploaded successfully');
      });
    });

    form.parse(req);

It may be wrong, not sure. It was a contributed example and I'm not super familiar with it. Your analysis sounds right and if it works correctly after and doesn't currently, feel free to make a pull request to update the example 👍

Pull request completed:

#202

Thanks!