0

では、ファイルのアップロードに bodyParser を使用することの長所と短所は何ですか?

bodyParser を使用すると、ファイルを /var/ ディレクトリに取得し、アップロード後に自分のディレクトリに移動します。これにより、名前のファイルやその他の情報に簡単にアクセスできますが、bodyParser がなければ、一度ファイルに何かを実行できます「完了」イベントがトリガーされます。

bodyParser をいつ使用するか、ファイルに関していつ使用しないかを知る方法はありますか?

4

1 に答える 1

0

を使用している場合express、ミドルウェアを の前にバインドできますbodyParser

このようなもの:

app.use( function( req, res, next ) {
    ... code here runs before bodyparser
    next();
    ... code here runs on the way back (only when there is no error)
});
app.use( express.bodyParser() );
app.use( function( req, res, next ) {
    ... code here runs after bodyparser, before route
    next();
    ... code here runs on the way back (only when there is no error)
});

この場合、両方を使用できます。

よろしくロバート

于 2013-05-23T16:11:03.247 に答える