Spaces:
Sleeping
Sleeping
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 | |
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) | |