21 lines
502 B
Python
21 lines
502 B
Python
from typing import List
|
|
from fastapi import APIRouter
|
|
from fastapi import UploadFile
|
|
import os
|
|
|
|
from app.config.config_reader import images_url
|
|
|
|
upload_files = APIRouter()
|
|
|
|
|
|
@upload_files.post("/")
|
|
def upload(files: List[UploadFile], project_no: str):
|
|
paths = []
|
|
for file in files:
|
|
path = os.path.join(images_url, project_no, file.filename)
|
|
with open(path, "wb") as f:
|
|
for line in file.file:
|
|
f.write(line)
|
|
paths.append(path)
|
|
return paths
|