Filesharing / config.py
nikhilyadavtemp1's picture
fix: use absolute paths for uploads to avoid Errno 2
ba29f7e
Raw History Blame Contribute Delete
631 Bytes
import os
# Use absolute path for UPLOAD_DIR to ensure reliability across different environments
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
UPLOAD_DIR = os.path.abspath(os.getenv("UPLOAD_DIR", os.path.join(BASE_DIR, "uploads")))
API_ID = os.getenv("API_ID")
API_HASH = os.getenv("API_HASH")
BOT_TOKEN = os.getenv("BOT_TOKEN") or os.getenv("TELEGRAM_TOKEN")
BASE_URL = os.getenv("BASE_URL", "https://ttnikal-filesharing.hf.space").rstrip("/")
if not os.path.exists(UPLOAD_DIR):
os.makedirs(UPLOAD_DIR, exist_ok=True)
# Ensure it's writable
try:
os.chmod(UPLOAD_DIR, 0o777)
except:
pass