2016-03-23 14 views
2

ile yükleme Bunu nasıl en üst seviyeye çıkaracağını anla. İşte bir yöntemi kullanarak mesai testidir başka yerde önerdi gördüm:Test Ekspres multer dosya dizisi Ben multer kullanır ve dosyaların dizisini alır bir post bitiş noktası var Supertest

Error: Unexpected field 
at makeError (/Users/Oscar/Google Drive/CompSci/COMPSCI-YEAR4/FinalProject/gpsapp/node_modules/multer/lib/make-error.js:12:13) 
at wrappedFileFilter (/Users/Oscar/Google Drive/CompSci/COMPSCI-YEAR4/FinalProject/gpsapp/node_modules/multer/index.js:39:19) 
at Busboy.<anonymous> (/Users/Oscar/Google Drive/CompSci/COMPSCI-YEAR4/FinalProject/gpsapp/node_modules/multer/lib/make-middleware.js:112:7) 
at emitMany (events.js:108:13) 
at Busboy.emit (events.js:182:7) 
at Busboy.emit (/Users/Oscar/Google Drive/CompSci/COMPSCI-YEAR4/FinalProject/gpsapp/node_modules/multer/node_modules/busboy/lib/main.js:31:35) 
at PartStream.<anonymous> (/Users/Oscar/Google Drive/CompSci/COMPSCI-YEAR4/FinalProject/gpsapp/node_modules/multer/node_modules/busboy/lib/types/multipart.js:208:13) 
at emitOne (events.js:77:13) 
at PartStream.emit (events.js:169:7) 
at HeaderParser.<anonymous> (/Users/Oscar/Google Drive/CompSci/COMPSCI-YEAR4/FinalProject/gpsapp/node_modules/multer/node_modules/busboy/node_modules/dicer/lib/Dicer.js:51:16) 
at emitOne (events.js:77:13) 
at HeaderParser.emit (events.js:169:7) 
at HeaderParser._finish (/Users/Oscar/Google Drive/CompSci/COMPSCI-YEAR4/FinalProject/gpsapp/node_modules/multer/node_modules/busboy/node_modules/dicer/lib/HeaderParser.js:68:8) 
at SBMH.<anonymous> (/Users/Oscar/Google Drive/CompSci/COMPSCI-YEAR4/FinalProject/gpsapp/node_modules/multer/node_modules/busboy/node_modules/dicer/lib/HeaderParser.js:40:12) 
at emitMany (events.js:108:13) 
at SBMH.emit (events.js:182:7) 
at SBMH._sbmh_feed (/Users/Oscar/Google Drive/CompSci/COMPSCI-YEAR4/FinalProject/gpsapp/node_modules/multer/node_modules/busboy/node_modules/dicer/node_modules/streamsearch/lib/sbmh.js:159:14) 
at SBMH.push (/Users/Oscar/Google Drive/CompSci/COMPSCI-YEAR4/FinalProject/gpsapp/node_modules/multer/node_modules/busboy/node_modules/dicer/node_modules/streamsearch/lib/sbmh.js:56:14) 
at HeaderParser.push (/Users/Oscar/Google Drive/CompSci/COMPSCI-YEAR4/FinalProject/gpsapp/node_modules/multer/node_modules/busboy/node_modules/dicer/lib/HeaderParser.js:46:19) 
at Dicer._oninfo (/Users/Oscar/Google Drive/CompSci/COMPSCI-YEAR4/FinalProject/gpsapp/node_modules/multer/node_modules/busboy/node_modules/dicer/lib/Dicer.js:197:25) 
at SBMH.<anonymous> (/Users/Oscar/Google Drive/CompSci/COMPSCI-YEAR4/FinalProject/gpsapp/node_modules/multer/node_modules/busboy/node_modules/dicer/lib/Dicer.js:127:10) 
at emitMany (events.js:108:13) 
at SBMH.emit (events.js:182:7) 
at SBMH._sbmh_feed (/Users/Oscar/Google Drive/CompSci/COMPSCI-YEAR4/FinalProject/gpsapp/node_modules/multer/node_modules/busboy/node_modules/dicer/node_modules/streamsearch/lib/sbmh.js:188:10) 
at SBMH.push (/Users/Oscar/Google Drive/CompSci/COMPSCI-YEAR4/FinalProject/gpsapp/node_modules/multer/node_modules/busboy/node_modules/dicer/node_modules/streamsearch/lib/sbmh.js:56:14) 
at Dicer._write (/Users/Oscar/Google Drive/CompSci/COMPSCI-YEAR4/FinalProject/gpsapp/node_modules/multer/node_modules/busboy/node_modules/dicer/lib/Dicer.js:109:17) 
at doWrite (_stream_writable.js:292:12) 
at writeOrBuffer (_stream_writable.js:278:5) 
at Dicer.Writable.write (_stream_writable.js:207:11) 
at Multipart.write (/Users/Oscar/Google Drive/CompSci/COMPSCI-YEAR4/FinalProject/gpsapp/node_modules/multer/node_modules/busboy/lib/types/multipart.js:285:24) 
at Busboy._write (/Users/Oscar/Google Drive/CompSci/COMPSCI-YEAR4/FinalProject/gpsapp/node_modules/multer/node_modules/busboy/lib/main.js:74:16) 
at doWrite (_stream_writable.js:292:12) 
at writeOrBuffer (_stream_writable.js:278:5) 
at Busboy.Writable.write (_stream_writable.js:207:11) 
at IncomingMessage.ondata (_stream_readable.js:528:20) 
at emitOne (events.js:77:13) 
at IncomingMessage.emit (events.js:169:7) 
at IncomingMessage.Readable.read (_stream_readable.js:360:10) 
at flow (_stream_readable.js:743:26) 
at resume_ (_stream_readable.js:723:3) 
at doNTCallback2 (node.js:439:9) 
at process._tickCallback (node.js:353:17) 

kimse bu POST son nokta için bir çalışma testini yazılı olarak bana yardımcı olabilir:

it('Add a session', function(done) { 
     api.post('/api/projects/' + projectId + '/sessions') 
      .set('X-Auth', tokenA) 
      .attach('files[0]', './test/files/d.zip') 
      .attach('files[1]', './test/files/m.csv') 
      .attach('files[2]', './test/files/o.15o.txt') 
      .attach('files[3]', './test/files/e.n') 
      .end(function(err, res) { 
       expect(res.status).to.equal(201) 
       done(err) 
      }) 
    }) 

Bu oldukça uzun bir hata verir? Teşekkürler.

cevap

2

aynı isme sadece attach dosyalar, bunlar bir diziye eklenen ve bu şekilde gönderilen olacak Yani çıkıyor, bu nedenle test altındaki ince çalıştı:

it('Add a session', function(done) { 
    api.post('/api/projects/' + projectId + '/sessions') 
     .set('X-Auth', tokenA) 
     .attach('files', './test/files/d.zip') 
     .attach('files', './test/files/m.csv') 
     .attach('files', './test/files/o.15o.txt') 
     .attach('files', './test/files/e.n') 
     .end(function(err, res) { 
      expect(res.status).to.equal(201) 
      done(err) 
     }) 
}) 
İlgili konular