Meteor Package for formidable

2019-03-05 09:11发布

I use the Meteor package tomi:upload-server for file upload. This package use the npm package formidable directly. This make some part of the package tomi:upload-server not compatible with Meteor (you get errors such as "Meteor code must always run within a Fiber.").

On atmospherejs.com there is the package andruschka:formidable but this is also the packaging of npm formidable without any intervention.

Is it theoretically possible to make formidable's IncomingForm compatible with Meteor (for the use of MongoDB)? Or if we consider the other side, is it possible to change tomi:upload-server to make it compatible with Meteor?

tomi:upload-server does nothing more then instantiating the IncomingForm (form = new formidable.IncomingForm()) and registering some event handler on it. One of this event handler call a callback to my code and inside the callback I cannot access the MongoDB.

1条回答
Viruses.
2楼-- · 2019-03-05 10:05

I patched tomi:upload-server with this commit wrapping an event handler completly in a Fiber. As a consequence the callback getDirectory is now called inside a Fiber. Fiber.

查看更多
登录 后发表回答