We can upload file using telegram-upload
library by using the following command on terminal
telegram-upload file1.mp4 /path/to/file2.mkv
But if I want to call this inside python function, How should I do it. I mean in a python function if users passes the file path as an argument, then that function should be able to upload the file to telegram server.It is not mentioned in the documentation.
In other words I want to ask how to execute or run shell commands from inside python function?
2
Answers
I found the solution.Using os module we can run command line strings inside python function i.e.
os.system('telegram-upload file1.mp4 /path/to/file2.mkv')
For
telegram-upload
you can useupload
method intelegram_upload.management
andfor
telegram-download
usedownload
method in the same file.Or you can see how they are implemented there.