2017-02-10 41 views
0

,這部分我 '/上傳' 路線的行爲在一個非常奇怪的方式:req.pipe(...)不點火在Heroku

console.log("1st point"); 
 

 
    var busboy = new Busboy({ headers: req.headers }); 
 
    busboy.on('field', function(fieldname, file, filename, encoding, mimetype) { 
 

 
     console.log("can never be reached"); 
 
    }); 
 

 
    req.pipe(busboy); 
 
    console.log("2nd point");

它從來沒有達到打雜功能和idk爲什麼。

在本地主機和亞馬遜Linux上一切正常,但在heroku上這部分代碼通常只是略過。它讓我瘋狂。謝謝你的幫助。

+0

我不確定這是否因爲Heroku爲dynos設置了文件系統。請參閱https://devcenter.heroku.com/articles/dynos#ephemeral-filesystem,看看它是否有幫助。 –

+0

thx,我在上面。將看看我能否解決它。 – Dima

回答

0

的問題是在

res.redirect('/profile');
這個函數被調用(和之前完成

req.pipe(busboy);

改變會話。IDK爲什麼它的工作在亞馬遜,可能是英雄虛擬機架構中的一些東西問題已經解決了通過添加以下代碼:

var req_stream = req.pipe(busboy); 
 
    req_stream.on('finish', function() { 
 
     res.redirect('/profile'); 
 
    });

而現在它工作正常在Heroku。