Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

formidable events not firing properly in kraken #504

Closed
parthdesai93 opened this issue Mar 20, 2018 · 1 comment
Closed

formidable events not firing properly in kraken #504

parthdesai93 opened this issue Mar 20, 2018 · 1 comment

Comments

@parthdesai93
Copy link

Hey,

I'm trying to upload a file to server which uses kraken. this is simple method inside my controllers folder.

router.post('/upload', function(req, res) {
    var form = formidable.IncomingForm();
    form.on('file', function(name, file) {
        console.log('found file', name);
    });

    form.on('progress', function(bytesReceived, bytesExpected) {
        console.log('bytesReceived', bytesReceived);
        console.log('bytesExpected', bytesExpected);
    });

    form.on('end', () => {
        console.log('done');
    });

    form.parse(req, function(err, fields, files) {
        // res.writeHead(200, { 'content-type': 'text/plain' });
        res.send('received upload:\n\n').status(200);
        // res.end(util.inspect({ fields: fields, files: files }));
    });
});

this is the middleware config in my config.json

"multipart": {
        "enabled": true,
        "priority": 0,
        "module": {
            "name": "kraken-js/middleware/multipart",
            "arguments": [
                {
                    "uploadDir": "path:tmp/upload",
                    "keepExtensions": true,
                    "hash": "sha1",
                    "multiples": false
                }
            ]
        }
    }

When i do make a post request with form-data, file does get uploaded in specified folder but the it only fires progress event once and doesn't fire end or file event. Ideally i would like to know when file has been uploaded so i can put that object to s3 and clean up that file.

I have tried google, stackoverflow, github issues but couldn't find anything related to this, so i hope it's ok to file this issue.

Cheers :)

@parthdesai93 parthdesai93 changed the title formidable events not firing propelry in kraken formidable events not firing properly in kraken Mar 20, 2018
@parthdesai93
Copy link
Author

Closing this issue, since i get access to formidable events by disabling the middleware.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant