Go to file
2023-08-15 17:53:54 +08:00
.github/workflows Add GitHub actions to do auto testing and upload code coverage (#11) 2023-07-09 23:17:09 +08:00
src auto config setup 2023-08-15 17:53:34 +08:00
test remove create-empty-file 2023-08-15 16:45:56 +08:00
.gitignore refactored command line 2023-07-31 02:59:04 +08:00
.prettierignore Add GitHub actions to do auto testing and upload code coverage (#11) 2023-07-09 23:17:09 +08:00
.prettierrc added unit tests for all existing apis 2023-07-09 22:36:53 +08:00
Dockerfile added login timeout 2023-08-03 17:30:51 +08:00
entrypoint.sh added login timeout 2023-08-03 17:30:51 +08:00
example-config.yaml Faster download 2023-08-14 05:20:36 +08:00
jest.config.js added webdav server 2023-07-29 01:03:46 +08:00
LICENSE Initial commit 2023-07-04 01:54:16 +08:00
package.json v1.0.7 2023-08-14 21:00:43 +08:00
README.md update readme 2023-08-15 17:53:54 +08:00
tsconfig.json fix tsconfig to resolve import error 2023-07-25 12:27:52 +08:00
yarn.lock Faster download 2023-08-14 05:20:36 +08:00

tgfs

Use telegram as file storage, with a command line tool and WebDAV server.

Test codecov npm version

Tested on Windows, Ubuntu, MacOS

Installation

Through NPM

$ npm install tgfs

Through Git

$ yarn install && yarn build
$ alias tgfs="yarn start:prod"

Use it as a WebDAV server

$ tgfs -w

or

$ tgfs --webdav

Tested WebDAV Clients:

cmd usage

  • ls

    $ tgfs cmd ls /
    
  • mkdir

    $ tgfs cmd mkdir /documents
    
    $ tgfs cmd mkdir -p /documents/pictures
    
  • cp

    $ tgfs cmd cp ~/some-file /
    
  • rm

    $ tgfs cmd rm /some-file
    
    $ tgfs cmd rm -r /some-folder
    

Step by Step Guide to Set up config

Automatically:

A config file will be auto-generated when you run the program for the first time. Just follow the instructions to create a Telegram app and a private channel to store the files.

Manually:

First step

  1. Duplicate the example-config.yaml file and name it config.yaml
  2. Go to Here, login with your phone number and create a Telegram app.
  3. Copy the api_id and api_hash from the Telegram app page (step 2) to the config file (telegram -> api_id / api_hash)

Set up the channel to store files

  1. Create a new Telegram private channel (New Channel in the menu on the left)
  2. There should be a message like "Channel created". Right click the message and copy the post link.
  3. The format of the link should be like https://t.me/c/1234567/1, where 1234567 is the channel id. Copy the channel id to the config file (telegram -> private_file_channel)

Config fields explanation

  • telegram

    • session_file: The file path to store the session data. If you want to use multiple accounts, you can set different session files for each account.
    • login_timeout: Time to wait before login attempt aborts (in milliseconds).
  • tgfs

    • download
      • porgress: Whether to show a progress bar when downloading files
      • chunk_size_kb: The chunk size in KB when downloading files. Bigger chunk size means less requests.
  • webdav

    • host: The host of the WebDAV server listening on.
    • port: The port of the WebDAV server listening on.
    • users: The users of the WebDAV server.
      • password: The password of the user.