Giter Club home page Giter Club logo

mount-url's Introduction

mount-url

mount a file from a http url as a local file using fuse from the CLI. uses http range requests and streaming.

NPM

installation

requires fuse. on mac you can brew install osxfuse

npm install -g mount-url

usage

mount-url <url>

will create a file in the current directory using the basename of the url. the file will appear like a normal file but will use http Range requests to support random access to the file

how it works

First we do a GET request to the URL provided, but abort it as soon as we have the headers. If the server doesn't return accept-ranges: bytes then mount-url won't work with this file and we abort (because we can't have random access to the file so it isn't worth it to mount as a fuse file).

Then we create a fuse directory in your os.tmpdir(), create a file in that directory, symlink a file in your process.cwd() to point to the tmp fuse mounted file, and then proxy requests for data to the file and convert them into HTTP range requests for the bytes that the fuse file requests.

This means you can mount a e.g. 10GB movie file, open VLC and skip to the middle of the movie and it can skip to the middle of the file without downloading the entire first half first (this is a contrived example as VLC already supports HTTP range requests).

JS API

first require it:

var mount = require('mount-url')

this returns a function that can be used to mount a url. it takes two arguments, a url and a callback. the callback will be called with err, cleanup. if there is an error, you don't have to cleanup. cleanup is a function that, if your file mounted successfully (e.g. if there was no err) you can call to unmount the file safely before exiting.

example

mount(someURL, function mounted (err, cleanup) {
  if (err) {
    console.error(err.message)
    process.exit(1)
  }
  process.on('SIGINT', function () {
    cleanup(function () {
      process.exit(1)
    })
  })
})

mount-url's People

Contributors

max-mapper avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

mount-url's Issues

No native build was found for runtime=node abi=57 platform=linux arch=ia32

When I try to mount an URL I get some error messages:

/usr/lib/node_modules/mount-url/node_modules/node-gyp-build/index.js:28
  throw new Error('No native build was found for runtime=' + runtime + ' abi=' + abi + ' platform=' + platform + ' arch=' + arch)
  ^

Error: No native build was found for runtime=node abi=57 platform=linux arch=ia32
    at Function.load.path (/usr/lib/node_modules/mount-url/node_modules/node-gyp-build/index.js:28:9)
    at load (/usr/lib/node_modules/mount-url/node_modules/node-gyp-build/index.js:13:23)
    at Object.<anonymous> (/usr/lib/node_modules/mount-url/node_modules/fuse-bindings/index.js:1:99)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)

Does not work with Samba and causes an error when using 'ls -l' on a mounted folder

When sharing a file via Samba that was mounted using this package, Samba misinterprets the nature of the directory in which the file is mounted, considering it a file rather than a directory and thus preventing access to the actual underlying file.

Additionally, when performing an 'ls -l' on the grandparent folder containing a mounted file, an error is produced for each mounted folder.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.