Skip to content

mkg20001/ipfs-multipart

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ipfs-multipart

build status js-standard-style

A set of utilities to help dealing with IPFS multipart.

Lead Maintainer

Hugo Dias

Install

npm i --save ipfs-multipart

Usage

const http = require('http')
const IPFSMultipart = require('ipfs-multipart')

http.createServer((req, res) => {
  if (req.method === 'POST' && req.headers['content-type']) {
    const parser = IPFSMultipart.reqParser(req)

    parser.on('file', (fileName, fileStream) => {
      console.log(`file ${fileName} start`)

      fileStream.on('data', (data) => {
        console.log(`file ${fileName} contents:`, data.toString())
      })

      fileStream.on('end', (data) => {
        console.log(`file ${fileName} end`)
      })
    })

    parser.on('end', () => {
      console.log('finished parsing')
      res.writeHead(200)
      res.end()
    })

    return
  }

  res.writeHead(404)
  res.end()
}).listen(5001, () => {
  console.log('server listening on port 5001')
})

License

MIT

About

A set of utilities to help dealing with IPFS multipart

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%