Search code examples
angularjsnode.jsgridfsangular-file-upload

Get data back after posting files to gridfs with angular-file-upload


I post files from my controller, to my server, where gridfs writes them. After that, there is a writestream.on('close') where I can console.log the file._id to the terminal.

How can I set a variable back in my angular controller to the file._id? The server doesn't know what angular is, so how can I access it? Also, the angular-file-upload automatically makes the post, so I'm not sure how I could add a callback.

https://github.com/nervgh/angular-file-upload


Solution

  • You can look at the examples for a full list of subscribers. This could be what you're looking for:

    uploader.onCompleteItem = function(fileItem, response, status, headers) {
        console.info('onCompleteItem', fileItem, response, status, headers);
    };