17 lines
533 B
Python
17 lines
533 B
Python
|
import requests
|
||
|
from pathlib import Path
|
||
|
from rich.console import Console
|
||
|
|
||
|
console = Console()
|
||
|
# TODO switch server component to be able to use S3 storage options
|
||
|
def _upload_to_oxo(file: Path, url: str = "https://0x0.st", expires: int = 2) -> str:
|
||
|
resp = requests.post(
|
||
|
url=url,
|
||
|
files={"file": open(file, "rb"), "expires": str(expires)},
|
||
|
)
|
||
|
if not resp.ok:
|
||
|
raise requests.exceptions.HTTPError()
|
||
|
console.log(f"Uploaded file {file} to {str(resp.content)}")
|
||
|
return str(resp.content).strip()
|
||
|
|