A Tricky-Hack to have your "INFINITE-STORAGE-API" using Telegram as a serving API !
Ogram split a file >= 19MB, in multiples chunks and send it throught the Telegram-bot. All the links of the running project :
- Python (3.x recommended)
- Pip3
- You need to have an account on Telegram
- Go to https://t.me/omega_gram_bot(Or create your own bot with Botfather)
- Start the bot by hitting the START button or just write
/start
and then ENTER, you will get in response, your chat_id, you will use it with requests to ogram API to send files.. - Mute notification of the bot (Optionnal but recommended, to notreceive notifications for each chunk you're sending)
- Go to your Telegram Settings > Advanced > Automatic media download and deactive it, that will prevent telegram to automatically download a chunk of a file you're uploading ! .
- Update your
example.cofig.txt
file toconfig.txt
and provide a valid token if you're using you're personnal bot. - Install dependencies:
pip3 install -r requirements.txt
- You need to start the bot First, you can use this command :
python -m app.bot.main
- You need to start the rest-api of Ogram on a new terminal too :
python -m app.server.main
- When you send a file using the API, you will get this king of response :
{
"file_key": "b2a478f4be5107925f784f9bae82dd66",
"json_map": {
"cloud_map": [
{
"chunk_id": "BQACAgQAAxkDAAMlXpCQBGKASJqwi934DgKAJaxcy1sAAr8KAAI85IlQvfC_toG-uZcYBA",
"chunk_name": "caae245e4620464197d5d4506d1f349e",
"datetime": 1586532357.3464897,
"tmp_link": "https://api.telegram.org/file/bot1152608995:AAFnj-WNcNaTc6XNLdSuci7s-vcJaJfeAi0/documents/file_26"
}
],
"file": {
"file_name": "bg.jpg",
"file_path": "./static/bg.jpg"
},
"file_map": {
"0": "caae245e4620464197d5d4506d1f349e"
},
"md5_sum": "b2a478f4be5107925f784f9bae82dd66"
},
"message": "Your file bg.jpg have been saved successfully !",
"status": "success"
}
NB: The Limit size have been fixed to 100MB as a limit for the APi, but it can be changed !
- Sanix-darker