Code Monkey home page Code Monkey logo

fibridge-proxy-rs's Introduction

Rationale and introduction available in the blog post.

The point of this is to allow your browser to "host" files which can be streamed over HTTP. This requires a proxy server to handle the HTTP requests and forward them to the browser over websockets.

Why would this be useful? If the user has a very large file (genomic data files can easily be in the 20GB-200GB range), and you want to make ranged requests to that file (ie only download specific chunks) as though it were hosted on a normal server, this will allow that. In iobio we use this to allow our backend system to access a user's local files for processing by backend tools such as samtools.

Example usage

First start up the proxy server. We'll assume it's publicly available at example.com. You can either download it from the release page, or see below for instructions on building.

Then start it up:

./fibridge-proxy-rs --port 9001

A few useful options:

sudo ./fibridge-proxy-rs --host fbrg.xyz --port 80 --ip-address 172.xxx.x.x --key keyfile.pem --cert certfile.pem --secure-port 443

Create a hoster object in the browser and host a file (see this page for information about the fibridge-host library):

const fibridge = require('fibridge-host');
fibridge.createHoster({ proxyAddress: 'example.com', port: 9001, secure: false }).then((hoster) => {

  const file = new File(["Hi there"], "file.txt", {
    type: "text/plain",
  });

  const path = '/' + file.name;

  hoster.hostFile(path, file);

  // This is necessary because fibridge automatically generates a randomized
  // hoster id which is included in the path.
  const fullPath = hoster.getHostedPath(path);
  const url = `http://example.com:9001${fullPath}`;

  console.log(url);
});

That will print out a URL for the hosted file. You can then retrieve the file using any http client:

curl example.com:9001/<hoster-uuid>/file.txt
Hi there

Ranged requests work too:

curl -H "Range: bytes=0-2" example.com:9001/<hoster-uuid>/file.txt
Hi

Building

In order to build from source, you'll first need rust installed. The proxy currently expects the GUI repo to be available in the same directory, like this:

fibridge/
  fibridge-proxy-rs/
  fibridge-gui-js/

See fibridge-gui-js for instructions on building the GUI.

Once the GUI is built, run:

cargo build --release

If all goes well you should end up with a binary in fibridge-proxy-rs/target/release.

Other implementations

There is an API-compatible JavaScript (Node) implementation of the proxy server available here.

API

I still need to document the API, but it's pretty simple. It uses omni-rpc, which is itself built on top of omnistreams.

fibridge-proxy-rs's People

Contributors

anderspitman 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  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

fibridge-proxy-rs's Issues

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.