dfd
This commit is contained in:
@@ -13,6 +13,7 @@ class ZeroXZero(Provider):
|
||||
|
||||
def upload(self, file_path: str, **kwargs: Any) -> str:
|
||||
from API.HTTP import HTTPClient
|
||||
from models import ProgressFileReader
|
||||
|
||||
if not os.path.exists(file_path):
|
||||
raise FileNotFoundError(f"File not found: {file_path}")
|
||||
@@ -21,7 +22,12 @@ class ZeroXZero(Provider):
|
||||
headers = {"User-Agent": "Medeia-Macina/1.0"}
|
||||
with HTTPClient(headers=headers) as client:
|
||||
with open(file_path, "rb") as handle:
|
||||
response = client.post("https://0x0.st", files={"file": handle})
|
||||
try:
|
||||
total = os.path.getsize(file_path)
|
||||
except Exception:
|
||||
total = None
|
||||
wrapped = ProgressFileReader(handle, total_bytes=total, label="upload")
|
||||
response = client.post("https://0x0.st", files={"file": wrapped})
|
||||
|
||||
if response.status_code == 200:
|
||||
uploaded_url = response.text.strip()
|
||||
|
||||
Reference in New Issue
Block a user