tgfs/README.md
2023-08-03 17:30:51 +08:00

2.1 KiB

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.