npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

remote-file-server

v0.0.2

Published

A remote file server that can be programmed to use AWS S3 or a custom daemon

Downloads

7

Readme

Remote File Server

A client-side library for putting, getting, removing and listing files on a remove file server. The client-side library can be configured to use AWS S3, or a custom file server. A custom file server is also supplied here.

The idea is to provide a client with remote file upload/download which can use S3 in production and the custom file server in test, or in an environment without access to S3. The client code does not change, only configuration changes.

Usage

var config = require( './config.json' );
var fileServer = require( 'remote-file-system' )( config.fileserver );
fileServer.upload( readableStream, "my-filename", "root-directory", function( err, bytes, url ) {
  if ( err ) exit( err );
  console.log( "uploaded file, size:", bytes, "native url:", url );
  exit();
});

By simply supplying different configuration, this can work with S3 or with the (supplied) custom file server.

Methods

upload( readableStream, pathname, root, function( err, bytes, url ) )

readableStream is the file content. pathnameis a relative path/filename of where you want to store the file, which will go underroot. For example, if pathnameis "images/img.png" androot` is "my-uploads" then the file will be stored on the file server as "my-uploads/images/img.png". When using S3 as the file server, then "my-uploads" is the bucket and "images/img.png" is the key. For S3, the "my-uploads" buckey must already exist.

The callback will return an error, or the number of bytes uploaded and the native url where this file was stored.

listing( root, [prefix,] function( err, listing ) )

The listing result will be an array of { name:, size: }. The prefix acts like the S3 documented "Prefix" parameter. That is, you always get a recursive listing of files from root (a bucket) and if prefix is non-null, only those files (keys) that begin with prefix.

remove( root, filename, function( err ) )

Remove the remote file.

get( root, filename, function( err, readableStream ) )

Get a file. The readableStream is the file content.

Custom File Server

You can run the following for a local file server instead of using S3:

env PORT=3000 BASEPATH=/tmp TRACE=1 node file-server.js

Configuration

Please look at "config-example.json" for configuration details.