mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: remake content upload and diffusion
This commit is contained in:
parent
aea9da388f
commit
fd0b5494cf
29 changed files with 345 additions and 162 deletions
|
|
@ -1,17 +1,17 @@
|
|||
import os
|
||||
|
||||
from src.services.utils.upload_content import upload_content
|
||||
|
||||
async def upload_thumbnail(thumbnail_file, name_in_disk):
|
||||
|
||||
async def upload_thumbnail(thumbnail_file, name_in_disk, org_id, course_id):
|
||||
contents = thumbnail_file.file.read()
|
||||
try:
|
||||
if not os.path.exists("content/uploads/img"):
|
||||
os.makedirs("content/uploads/img")
|
||||
|
||||
with open(f"content/uploads/img/{name_in_disk}", 'wb') as f:
|
||||
f.write(contents)
|
||||
f.close()
|
||||
await upload_content(
|
||||
f"courses/{course_id}/thumbnails",
|
||||
org_id,
|
||||
contents,
|
||||
f"{name_in_disk}",
|
||||
)
|
||||
|
||||
except Exception:
|
||||
return {"message": "There was an error uploading the file"}
|
||||
finally:
|
||||
thumbnail_file.file.close()
|
||||
Loading…
Add table
Add a link
Reference in a new issue