Go to file
2023-08-04 18:41:07 +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 WebDAV: unit tests 2023-08-04 18:41:07 +08:00
test WebDAV: unit tests 2023-08-04 18:41:07 +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 added login timeout 2023-08-03 17:30:51 +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 WebDAV: unit tests 2023-08-04 18:41:07 +08:00
README.md added login timeout 2023-08-03 17:30:51 +08:00
tsconfig.json fix tsconfig to resolve import error 2023-07-25 12:27:52 +08:00
yarn.lock WebDAV: unit tests 2023-08-04 18:41:07 +08:00

tgfs

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

Test codecov

Tested on Windows, Ubuntu, MacOS

Installation

Through Git

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

Step by Step Guide to Set up config

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)

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
    

Use it as a WebDAV server

$ tgfs -w

or

$ tgfs --webdav

Tested WebDAV Clients:

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.
  • 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.