このような投稿リクエストを処理する高速アプリがあります(coffeescript)
#Handle CSV Uploads
app.post '/upload', (req, res) ->
res.setHeader 'Content-Type', 'text/json'
if !req.session.user?
res.json
success: false
return
if !req.files.files? || !req.files.files.length
res.json
success: false
message: 'No Files Uploaded'
return
file = req.files.files[0]
if file.mime is not 'text/csv'
res.json
success: false
message: 'Invalid Upload Type'
return
#Find IDs of all shippers referenced in this csv
client_shippers_ids = []
chainer = new Sequelize.Utils.QueryChainer
csv()
.from.stream(fs.createReadStream(file.path))
.to.path('/tmp/tempcsv.out')
.transform((row) ->
return row
).on('record', (row, index)->
chainer.add DB.Order.create
po_num: Math.random() + ''
description: Math.random() + ''
requested_by: ''
received: false
status: 'Purchase Order Received'
).on('end', (count)->
console.log 'end'
console.log count
chainer.run().success () ->
console.log 'chainer fin'
res.json #<----- This part does not send
success: true
message: 'complete'
)
具体的にはこの呼び出し
res.json #<----- This part does not send
success: true
message: 'complete'
何も返しません。この前に res.end() が呼び出されていますか?