亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

node.js - nodejs how to store formdata data (file) as blob data of mongodb
過去多啦不再A夢
過去多啦不再A夢 2017-05-16 13:32:45
0
2
1026

The front-end uploads a file file through formdata
The back-end framework is koa, and the co-busboy middleware is used to parse the request.
There is a simple example in the co-busboy document that can obtain a "file stream" through parsing "FileStream, and then write the file locally through the fs module of node. This is quite simple.

Now my problem is that I want to store the file in the form of blob instead of storing it locally.
Then I am thinking about how to transfer from FileStream.
This FileStream is printed as follows:

FileStream {
  _readableState:
   ReadableState {
     objectMode: false,
     highWaterMark: 16384,
     buffer: BufferList { head: [Object], tail: [Object], length: 1 },
     length: 10256,
     pipes: null,
     pipesCount: 0,
     flowing: null,
     ended: false,
     endEmitted: false,
     reading: true,
     sync: false,
     needReadable: true,
     emittedReadable: false,
     readableListening: false,
     resumeScheduled: false,
     defaultEncoding: 'utf8',
     ranOut: false,
     awaitDrain: 0,
     readingMore: false,
     decoder: null,
     encoding: null },
  readable: true,
  domain: null,
  _events: { end: [Function] },
  _eventsCount: 1,
  _maxListeners: undefined,
  truncated: false,
  _read: [Function],
  fieldname: 'homework',
  filename: '2017-1-18.json',
  encoding: '7bit',
  transferEncoding: '7bit',
  mime: 'application/octet-stream',
  mimeType: 'application/octet-stream' }

At that time, I saw an attribute called buffer, and I also tried the Buffer module in node, but it didn't seem to work.

In short, the question is how to convert the file stream to blob format?
Please give me some guidance

過去多啦不再A夢
過去多啦不再A夢

reply all(2)
伊謝爾倫

Decided not to store the files in the database

過去多啦不再A夢

MongoDB does not blob格式,你需要的是GridFS. Take a look at the driver documentation first, there are examples in it. If there is anything you don’t understand, discuss it later.
https://mongodb.github.io/nod...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template