{"id":22840897,"url":"https://github.com/mkloubert/node-share-folder","last_synced_at":"2025-03-31T04:38:22.359Z","repository":{"id":57357941,"uuid":"133441146","full_name":"mkloubert/node-share-folder","owner":"mkloubert","description":"API and CLI application to run a REST host for sharing files and folders.","archived":false,"fork":false,"pushed_at":"2018-05-18T03:43:48.000Z","size":269,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-06T09:14:01.791Z","etag":null,"topics":["cli-application","file-sharing","fileserver","http","https","javascript","node-module","rest-api","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mkloubert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-15T01:20:51.000Z","updated_at":"2018-05-19T05:28:26.000Z","dependencies_parsed_at":"2022-09-26T16:33:22.123Z","dependency_job_id":null,"html_url":"https://github.com/mkloubert/node-share-folder","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkloubert%2Fnode-share-folder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkloubert%2Fnode-share-folder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkloubert%2Fnode-share-folder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkloubert%2Fnode-share-folder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mkloubert","download_url":"https://codeload.github.com/mkloubert/node-share-folder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246418698,"owners_count":20773935,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli-application","file-sharing","fileserver","http","https","javascript","node-module","rest-api","typescript"],"created_at":"2024-12-13T01:14:00.479Z","updated_at":"2025-03-31T04:38:22.333Z","avatar_url":"https://github.com/mkloubert.png","language":"TypeScript","funding_links":["https://paypal.me/MarcelKloubert"],"categories":[],"sub_categories":[],"readme":"[![npm](https://img.shields.io/npm/v/share-folder.svg)](https://www.npmjs.com/package/share-folder)\n[![npm](https://img.shields.io/npm/dt/share-folder.svg?label=npm%20downloads)](https://www.npmjs.com/package/share-folder)\n\n# node-share-folder\n\nAPI and CLI application to run a REST host for sharing files and folders, written for [Node.js 7+](https://nodejs.org).\n\n## Install\n\n### As command line tool\n\n```bash\nnpm install -g share-folder\n```\n\n### As module\n\n```bash\nnpm install --save share-folder\n```\n\n## Usage\n\n### Command line\n\nShare current folder:\n\n```bash\nshare-folder\n```\n\nShow help:\n\n```bash\nshare-folder --?\n```\n\nShare custom folder:\n\n```bash\nshare-folder /path/to/folder/to/share\n```\n\nRun in SSL mode:\n\n```bash\nshare-folder --cert=/path/to/ca/file --key=/path/to/key/file\n```\n\nDefine username and password:\n\n```bash\nshare-folder --user=mkloubert --password=P@ssword123!\n```\n\nAllow clients to write:\n\n```bash\nshare-folder --can-write\n```\n\nUpload a file:\n\n```bash\nshare-folder --upload /path/to/file/on/remote.txt \u003c ./file-to-upload.txt\n```\n\nDownload a file:\n\n```bash\nshare-folder --download /path/to/file/on/remote.txt \u003e ./downloaded-file.txt\n```\n\nRemove a file or folder:\n\n```bash\nshare-folder --delete /path/to/file/or/folder/on/remote\n```\n\n### Module\n\nComplete documentation about the classes, interfaces and functions can be found [here](https://mkloubert.github.io/node-share-folder/).\n\n#### Run host\n\n```typescript\nimport { ShareFolderHost } from 'share-folder';\n\nconst HOST = new ShareFolderHost({\n    port: 44444,  // default: 55555\n    root: '/path/to/root/folder',\n});\n\nawait HOST.start();\n```\n\n#### Use client\n\n```typescript\nimport * as fs from 'from';\nimport { ShareFolderClient } from 'share-folder';\n\nconst CLIENT = new ShareFolderClient({\n    host: 'example.com',\n    port: 44444,\n});\n\n// list directory\nconst LIST = await CLIENT.list('/path/to/directory/on/remote');\nfor (const ITEM of LIST) {\n    // TODO\n}\n\n// upload a file\nawait CLIENT.upload('/path/to/file/on/remote.txt',\n                    fs.readFileSync('/path/of/file/to/upload'));\n\n// download file\nfs.writeFileSync(\n    '/path/to/downloaded/file.txt',\n    await CLIENT.download('/path/to/file/on/remote.txt')\n);\n\n// delete file or folder\nawait CLIENT.remove('/path/to/file/or/folder/on/remote');\n```\n\n## API\n\n### [DELETE] /path/to/file/or/folder/to/delete\n\nDeletes a file or folder.\n\nExample:\n\n```http\nDELETE /my-file-or-folder\n```\n\nPossible respose:\n\n```http\nHTTP/1.1 200 OK\nConnection: close\nContent-Length: 114\nContent-Type: application/json; charset=utf8\nDate: Tue, 15 May 2018 19:25:19 GMT\nETag: W/\"72-oPrCQJagCLUSh2PmGv+W7S+xo4M\"\nX-Powered-By: node-share-folder (Express)\nX-Tm-Mk: 1979-09-05T23:09:00.000Z\n\n{\n  \"ctime\": \"2018-05-15T19:11:17.082Z\",\n  \"mtime\": \"2018-05-15T19:11:17.082Z\",\n  \"name\": \"my-file-or-folder\",\n  \"size\": 0,\n  \"type\": 1\n}\n```\n\n### [GET] /path/to/file/or/folder\n\n#### List a directory\n\nExample:\n\n```http\nGET /\n```\n\nPossible respose:\n\n```http\nHTTP/1.1 200 OK\nConnection: close\nContent-Length: 218\nContent-Type: application/json; charset=utf8\nDate: Tue, 15 May 2018 17:20:59 GMT\nETag: W/\"da-sIP9lRV14VgW0g/mFthDumv5hqE\"\nX-Powered-By: node-share-folder (Express)\nX-Share-Folder-Type: d\nX-Tm-Mk: 1979-09-05T23:09:00.000Z\n\n[\n  {\n    \"ctime\": \"2018-05-15T03:20:43.536Z\",\n    \"mtime\": \"2018-05-15T03:20:43.536Z\",\n    \"name\": \"test-folder\",\n    \"size\": 0,\n    \"type\": 1\n  },\n  {\n    \"ctime\": \"2018-05-15T17:13:40.979Z\",\n    \"mtime\": \"2018-05-15T17:13:40.979Z\",\n    \"name\": \"test-file.txt\",\n    \"size\": 22,\n    \"type\": 2\n  }\n]\n```\n\n#### Get content of a file\n\nExample:\n\n```http\nGET /test-file.txt\n```\n\nPossible respose:\n\n```http\nHTTP/1.1 200 OK\nConnection: close\nContent-Disposition: attachment; filename=\"test-file.txt\"\nContent-Length: 1706\nContent-Type: text/plain\nDate: Tue, 15 May 2018 17:22:38 GMT\nETag: W/\"16-MKQSnrz7Udk6d5pTlq5C66K847M\"\nX-Powered-By: node-share-folder (Express)\nX-Share-Folder-Type: f\nX-Tm-Mk: 1979-09-05T23:09:00.000Z\n\nLorem 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. \n\nDuis 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. \n\nUt 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. \n```\n\n#### Get info of a file or folder\n\n```http\nGET /test-file.txt?info=1\n```\n\nPossible response:\n\n```http\nHTTP/1.1 200 OK\nConnection: close\nContent-Length: 112\nContent-Type: application/json; charset=utf8\nDate: Tue, 15 May 2018 17:38:37 GMT\nETag: W/\"70-z+vwPpHUvk692rkWEZzIZHAhJU4\"\nX-Powered-By: node-share-folder (Express)\nX-Tm-Mk: 1979-09-05T23:09:00.000Z\n\n{\n  \"ctime\": \"2018-05-15T17:24:07.094Z\",\n  \"mtime\": \"2018-05-15T17:24:07.094Z\",\n  \"name\": \"test.txt\",\n  \"size\": 1706,\n  \"type\": 2\n}\n```\n\n### [POST] /path/to/folder/to/create\n\nCreates a new directory.\n\n```http\nPOST /my-new-folder\n```\n\nPossible response:\n\n```http\nHTTP/1.1 200 OK\nConnection: close\nContent-Length: 101\nContent-Type: application/json; charset=utf8\nDate: Tue, 15 May 2018 19:11:17 GMT\nETag: W/\"65-A0B7XUVLv2NMnQ0vYHwV2lBVbgo\"\nX-Powered-By: node-share-folder (Express)\nX-Tm-Mk: 1979-09-05T23:09:00.000Z\n\n{\n  \"ctime\": \"2018-05-15T19:11:17.082Z\",\n  \"mtime\": \"2018-05-15T19:11:17.082Z\",\n  \"name\": \"my-new-folder\",\n  \"size\": 0,\n  \"type\": 1\n}\n```\n\n### [PUT] /path/to/file\n\nWrites to a file.\n\n```http\nPUT /my-file\n\nLorem ispum\n```\n\nPossible response:\n\n```http\nHTTP/1.1 200 OK\nConnection: close\nContent-Length: 102\nContent-Type: application/json; charset=utf8\nDate: Tue, 15 May 2018 19:14:11 GMT\nETag: W/\"66-b5W/DNIHdZfEUzg6h+WRj/oDsVA\"\nX-Powered-By: node-share-folder (Express)\nX-Tm-Mk: 1979-09-05T23:09:00.000Z\n\n{\n  \"ctime\": \"2018-05-15T19:14:11.079Z\",\n  \"mtime\": \"2018-05-15T19:14:11.079Z\",\n  \"name\": \"my-file\",\n  \"size\": 11,\n  \"type\": 2\n}\n```\n\n## Support and contribute\n\nIf you like the module, you can support the project by sending a [donation via PayPal](https://paypal.me/MarcelKloubert) to [me](https://github.com/mkloubert).\n\nTo contribute, you can [open an issue](https://github.com/mkloubert/node-share-folder/issues) and/or fork this repository.\n\nTo work with the code:\n\n* clone [this repository](https://github.com/mkloubert/node-share-folder)\n* create and change to a new branch, like `git checkout -b my_new_feature`\n* run `npm install` from your project folder\n* open that project folder in Visual Studio Code\n* now you can edit and debug there\n* commit your changes to your new branch and sync it with your forked GitHub repo\n* make a [pull request](https://github.com/mkloubert/node-share-folder/pulls)\n\n## Related projects\n\n### node-enumerable\n\n[node-enumerable](https://github.com/mkloubert/node-enumerable) is a [LINQ](https://en.wikipedia.org/wiki/Language_Integrated_Query) implementation for JavaScript, which runs in [Node.js](https://nodejs.org/) and browsers.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkloubert%2Fnode-share-folder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmkloubert%2Fnode-share-folder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkloubert%2Fnode-share-folder/lists"}