htfs
Expose filesystem via HTTP and access it from the other side!
Last updated 2 years ago by pi0 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install htfs 
SYNC missed versions from official npm registry.

HTTP Filesystem

npm version npm downloads package phobia

Standard JS david dm codecov circleci

Expose filesystem via HTTP and access it from the other side!

This module works best with memory-fs.

Install

Install package:

yarn add htfs

OR

npm install htfs

Server

Serving real fs is not a good idea. In this example we serve a virtual filesystem.

const HTTPFSMiddleware = require('htfs/lib/middleware')
const express = require('express')
const MFS = require('memory-fs')

// Create a new express app listening on port 8080
const app = express()
app.listen(8080)

// Create a new Virtual FileSystem with a test file
const mfs = new MFS()
mfs.mkdirpSync('/test')
mfs.writeFileSync('/test/file.txt', 'Works!')

// Create and register fs middleware
app.use('/mfs', HTTPFSMiddleware(mfs))

You can now browse filesystem with broweser: http://localhost:8080/mfs/

Client

Supported methods:

  • exists(path): Promise<Boolean>
  • readFile(path): Promise<String>
const HTTPFSAClient = require('htfs/lib/client')

const fs = new HTTPFSAClient({
  endpoint: 'http://localhost:8080/mfs'
})

fs.readFile('/test/file.txt').then((contents) => {
  console.log('File contents:', contents)
})

Options

endpoint

Required. HTTP URL of server.

License

MIT. Made with ????

Current Tags

  • 0.0.3                                ...           latest (2 years ago)

3 Versions

  • 0.0.3                                ...           2 years ago
  • 0.0.2                                ...           2 years ago
  • 0.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (12)

Copyright 2014 - 2017 © taobao.org |