New web ui
This commit is contained in:
1 parent
a360fd9c63
commit
caee27c3ea
11 files changed
+248
-16
No files matched your search
@@ -55,6 +55,12 @@ class ImageHostClient:
|
||||
body = response.read()
|
||||
content_type = response.headers.get_content_type() or "image/jpeg"
|
||||
file_name = f"vk-{photo.get('owner_id', 'photo')}-{photo.get('id', 'upload')}.jpg"
|
||||
return self.upload_bytes(body, file_name, content_type)
|
||||
|
||||
def upload_bytes(self, body: bytes, file_name: str, content_type: str = "image/jpeg") -> str | None:
|
||||
"""Загружает произвольный файл на image-host и возвращает прямую ссылку."""
|
||||
if not self.api_url or not body:
|
||||
return None
|
||||
initiate = self._request_json(
|
||||
"/api/uploads/initiate",
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user