File size: 1,642 Bytes
9ff40ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import os
import requests
from pyrogram import Client, filters
from config import MAX_FILE_SIZE


def upload_to_transfersh(file_path):
    url = 'https://0x0.st'
    file = {'file': ('@' + file_path, open(file_path, 'rb'))}
    response = requests.post(url, files=file)
    download_link = response.content.decode('utf-8')
    return download_link


@Client.on_message(filters.private
                   & (filters.document | filters.photo | filters.audio | filters.video))
async def upload(client, message):


    if (message.document and message.document.file_size > MAX_FILE_SIZE):
        await message.reply_text(
            f'File is too big.\n\nFile size: {message.document.file_size}'
        )
        return
    if (message.photo and message.photo.file_size > MAX_FILE_SIZE):
        await message.reply_text(
            f'Photo is too big.\n\nFile size: {message.photo.file_size}'
        )
        return
    if (message.audio and message.audio.file_size > MAX_FILE_SIZE):
        await message.reply_text(
            f'Audio is too big.\n\nFile size: {message.audio.file_size}'
        )
        return
    if (message.video and message.video.file_size > MAX_FILE_SIZE):
        await message.reply_text(
            f'Video is too big.\n\nFile size: {message.video.file_size}'
        )
        return


    path = await message.download()
    if not path:
        return

    link = upload_to_transfersh(path).removesuffix('\n')

    os.remove(path)

    await message.reply_text(f"File's Download Page:\n\n{link}"
               
                             f'\n\nDownload Link might expire after 30 days...', quote=True)