23 / resumable.js

A JavaScript library for providing multiple simultaneous, stable, fault-tolerant and resumable/restartable uploads via the HTML5 File API.
MIT License
4.65k stars 611 forks source link

Node.JS: Cannot read property 'toString' of undefined (empty request body and files) #601

Open loretoparisi opened 2 years ago

loretoparisi commented 2 years ago

I have fixed the Node.JS with small deprecated warning, but I'm getting an empty body here:

 $.post = function (req, callback) { 
    var fields = req.body; // <--- this is empty
    var files = req.files; // <--- this is empty
    //...

That is called as usually:

self.app.post(self._options.baseUrl + '/upload', function (req, res) {
                resumableServer.post(req,
                    function (status, filename, original_filename, identifier) {
                        self.logger.debug("upload %s to %s", original_filename, filename);
                        if (status === "done") {
                            var s = fs.createWriteStream(
                                "/root/" + filename
                            );
                            s.on("finish", function () {
                                resumableServer.clean(identifier);
                                res.status(200).send();
                            });
                            resumableServer.write(identifier, s, { end: true });
                        } else {
                            res.status(/^(partly_done|done)$/.test(status) ? 200 : 500).send();
                        }
                    }
                );
            });

while the example client is like this example. Here the whole client gist.