co-busboy 解析流如何处理呢?--在线等--
发布于 10 年前 作者 petitspois 6471 次浏览 最后一次编辑是 8 年前 来自 问答

github问题连接

//fs.createReadStream(part.filename)

{ _readableState:
  { objectMode: false,
    highWaterMark: 65536,
    buffer: [],
    length: 0,
    pipes: null,
    pipesCount: 0,
    flowing: null,
    ended: false,
    endEmitted: false,
    reading: false,
    sync: true,
    needReadable: false,
    emittedReadable: false,
    readableListening: false,
    defaultEncoding: 'utf8',
    ranOut: false,
    awaitDrain: 0,
    readingMore: false,
    decoder: null,
    encoding: null },
 readable: true,
 domain: null,
 _events: { end: [Function] },
 _maxListeners: undefined,
 path: '8644ebf81a4c510f9eaed41d6359252dd42aa54a.jpg',
 fd: null,
 flags: 'r',
 mode: 438,
 start: undefined,
 end: undefined,
 autoClose: true,
 pos: undefined }

//co-body 处理后的流 //var parts = parse(this,{autoFields: true}); //var part = yield parts;

{ _readableState:
  { objectMode: false,
    highWaterMark: 16384,
    buffer: [ <Buffer ff d8 ff e0 00 10 4a 46 49 46 00 01 01 01 00 60 00 60 00 00 ff db 00 43 00 03 02 02 03 02 02 03 03 03 03 04 03 03 04 05 08 05 05 04 04 05 0a 07 07 06 ... > ],
    length: 10902,
    pipes:
     { _writableState: [Object],
       writable: true,
       domain: null,
       _events: [Object],
       _maxListeners: undefined,
       path: '8644ebf81a4c510f9eaed41d6359252dd42aa54a.jpg',
       fd: null,
       flags: 'w',
       mode: 438,
       start: undefined,
       pos: undefined,
       bytesWritten: 0 },
    pipesCount: 1,
    flowing: true,
    ended: false,
    endEmitted: false,
    reading: false,
    sync: true,
    needReadable: false,
    emittedReadable: false,
    readableListening: false,
    defaultEncoding: 'utf8',
    ranOut: false,
    awaitDrain: 0,
    readingMore: true,
    decoder: null,
    encoding: null,
    resumeScheduled: true },
 readable: true,
 domain: null,
 _events: { end: [ [Function], [Object] ], data: [Function: ondata] },
 _maxListeners: undefined,
 truncated: false,
 _read: [Function],
 fieldname: 'file',
 filename: '8644ebf81a4c510f9eaed41d6359252dd42aa54a.jpg',
 encoding: '7bit',
 transferEncoding: '7bit',
 mime: 'image/jpeg',
 mimeType: 'image/jpeg' }

应该如何处理呢?用//fs.createReadStream 是成功的。

1 回复

解决了。

store.upload(part, {filename:part.filename, contentType:part.mimeType}, function(err, ret){
            console.log(ret)
        });

或者 part.path 添加filename :)

回到顶部