Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
/ js-ipfs Public archive

IPFS implementation in JavaScript

License

Unknown and 2 other licenses found

Licenses found

Unknown
LICENSE
Unknown
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

ipfs/js-ipfs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ipfs-multipart

build status js-standard-style

A set of utilities to help dealing with IPFS multipart.

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