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

share-folder

v0.11.1

Published

API and CLI application to run a REST host for sharing files and folders.

Downloads

32

Readme

npm npm

node-share-folder

API and CLI application to run a REST host for sharing files and folders, written for Node.js 7+.

Install

As command line tool

npm install -g share-folder

As module

npm install --save share-folder

Usage

Command line

Share current folder:

share-folder

Show help:

share-folder --?

Share custom folder:

share-folder /path/to/folder/to/share

Run in SSL mode:

share-folder --cert=/path/to/ca/file --key=/path/to/key/file

Define username and password:

share-folder --user=mkloubert --password=P@ssword123!

Allow clients to write:

share-folder --can-write

Upload a file:

share-folder --upload /path/to/file/on/remote.txt < ./file-to-upload.txt

Download a file:

share-folder --download /path/to/file/on/remote.txt > ./downloaded-file.txt

Remove a file or folder:

share-folder --delete /path/to/file/or/folder/on/remote

Module

Complete documentation about the classes, interfaces and functions can be found here.

Run host

import { ShareFolderHost } from 'share-folder';

const HOST = new ShareFolderHost({
    port: 44444,  // default: 55555
    root: '/path/to/root/folder',
});

await HOST.start();

Use client

import * as fs from 'from';
import { ShareFolderClient } from 'share-folder';

const CLIENT = new ShareFolderClient({
    host: 'example.com',
    port: 44444,
});

// list directory
const LIST = await CLIENT.list('/path/to/directory/on/remote');
for (const ITEM of LIST) {
    // TODO
}

// upload a file
await CLIENT.upload('/path/to/file/on/remote.txt',
                    fs.readFileSync('/path/of/file/to/upload'));

// download file
fs.writeFileSync(
    '/path/to/downloaded/file.txt',
    await CLIENT.download('/path/to/file/on/remote.txt')
);

// delete file or folder
await CLIENT.remove('/path/to/file/or/folder/on/remote');

API

[DELETE] /path/to/file/or/folder/to/delete

Deletes a file or folder.

Example:

DELETE /my-file-or-folder

Possible respose:

HTTP/1.1 200 OK
Connection: close
Content-Length: 114
Content-Type: application/json; charset=utf8
Date: Tue, 15 May 2018 19:25:19 GMT
ETag: W/"72-oPrCQJagCLUSh2PmGv+W7S+xo4M"
X-Powered-By: node-share-folder (Express)
X-Tm-Mk: 1979-09-05T23:09:00.000Z

{
  "ctime": "2018-05-15T19:11:17.082Z",
  "mtime": "2018-05-15T19:11:17.082Z",
  "name": "my-file-or-folder",
  "size": 0,
  "type": 1
}

[GET] /path/to/file/or/folder

List a directory

Example:

GET /

Possible respose:

HTTP/1.1 200 OK
Connection: close
Content-Length: 218
Content-Type: application/json; charset=utf8
Date: Tue, 15 May 2018 17:20:59 GMT
ETag: W/"da-sIP9lRV14VgW0g/mFthDumv5hqE"
X-Powered-By: node-share-folder (Express)
X-Share-Folder-Type: d
X-Tm-Mk: 1979-09-05T23:09:00.000Z

[
  {
    "ctime": "2018-05-15T03:20:43.536Z",
    "mtime": "2018-05-15T03:20:43.536Z",
    "name": "test-folder",
    "size": 0,
    "type": 1
  },
  {
    "ctime": "2018-05-15T17:13:40.979Z",
    "mtime": "2018-05-15T17:13:40.979Z",
    "name": "test-file.txt",
    "size": 22,
    "type": 2
  }
]

Get content of a file

Example:

GET /test-file.txt

Possible respose:

HTTP/1.1 200 OK
Connection: close
Content-Disposition: attachment; filename="test-file.txt"
Content-Length: 1706
Content-Type: text/plain
Date: Tue, 15 May 2018 17:22:38 GMT
ETag: W/"16-MKQSnrz7Udk6d5pTlq5C66K847M"
X-Powered-By: node-share-folder (Express)
X-Share-Folder-Type: f
X-Tm-Mk: 1979-09-05T23:09:00.000Z

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. 

Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. 

Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. 

Get info of a file or folder

GET /test-file.txt?info=1

Possible response:

HTTP/1.1 200 OK
Connection: close
Content-Length: 112
Content-Type: application/json; charset=utf8
Date: Tue, 15 May 2018 17:38:37 GMT
ETag: W/"70-z+vwPpHUvk692rkWEZzIZHAhJU4"
X-Powered-By: node-share-folder (Express)
X-Tm-Mk: 1979-09-05T23:09:00.000Z

{
  "ctime": "2018-05-15T17:24:07.094Z",
  "mtime": "2018-05-15T17:24:07.094Z",
  "name": "test.txt",
  "size": 1706,
  "type": 2
}

[POST] /path/to/folder/to/create

Creates a new directory.

POST /my-new-folder

Possible response:

HTTP/1.1 200 OK
Connection: close
Content-Length: 101
Content-Type: application/json; charset=utf8
Date: Tue, 15 May 2018 19:11:17 GMT
ETag: W/"65-A0B7XUVLv2NMnQ0vYHwV2lBVbgo"
X-Powered-By: node-share-folder (Express)
X-Tm-Mk: 1979-09-05T23:09:00.000Z

{
  "ctime": "2018-05-15T19:11:17.082Z",
  "mtime": "2018-05-15T19:11:17.082Z",
  "name": "my-new-folder",
  "size": 0,
  "type": 1
}

[PUT] /path/to/file

Writes to a file.

PUT /my-file

Lorem ispum

Possible response:

HTTP/1.1 200 OK
Connection: close
Content-Length: 102
Content-Type: application/json; charset=utf8
Date: Tue, 15 May 2018 19:14:11 GMT
ETag: W/"66-b5W/DNIHdZfEUzg6h+WRj/oDsVA"
X-Powered-By: node-share-folder (Express)
X-Tm-Mk: 1979-09-05T23:09:00.000Z

{
  "ctime": "2018-05-15T19:14:11.079Z",
  "mtime": "2018-05-15T19:14:11.079Z",
  "name": "my-file",
  "size": 11,
  "type": 2
}

Support and contribute

If you like the module, you can support the project by sending a donation via PayPal to me.

To contribute, you can open an issue and/or fork this repository.

To work with the code:

  • clone this repository
  • create and change to a new branch, like git checkout -b my_new_feature
  • run npm install from your project folder
  • open that project folder in Visual Studio Code
  • now you can edit and debug there
  • commit your changes to your new branch and sync it with your forked GitHub repo
  • make a pull request

Related projects

node-enumerable

node-enumerable is a LINQ implementation for JavaScript, which runs in Node.js and browsers.