25 lines
743 B
Python
25 lines
743 B
Python
|
|
from ninja import Router
|
||
|
|
from ninja import Router, UploadedFile, File
|
||
|
|
import os
|
||
|
|
from fuadmin import settings
|
||
|
|
|
||
|
|
router = Router()
|
||
|
|
|
||
|
|
# @router.get("/uploadFile")
|
||
|
|
# def upload_file(request, files: list[UploadedFile] = File(...)):
|
||
|
|
# file_list = []
|
||
|
|
# upload_dir = os.path.join(settings.BASE_DIR, 'upload')
|
||
|
|
# os.makedirs(upload_dir, exist_ok=True)
|
||
|
|
|
||
|
|
# for file in files:
|
||
|
|
# new_path = os.path.join(upload_dir, file.name)
|
||
|
|
# with open(new_path, 'wb+') as destination:
|
||
|
|
# for chunk in file.chunks():
|
||
|
|
# destination.write(chunk)
|
||
|
|
# file_list.append({
|
||
|
|
# 'name': file.name,
|
||
|
|
# 'path': new_path,
|
||
|
|
# 'size': file.size
|
||
|
|
# })
|
||
|
|
|
||
|
|
# return file_list
|