feat: remake content upload and diffusion

This commit is contained in:
swve 2023-06-28 21:03:25 +02:00
parent aea9da388f
commit fd0b5494cf
29 changed files with 345 additions and 162 deletions

View file

@ -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()