20 lines
416 B
Python
20 lines
416 B
Python
from typing import List
|
|
|
|
from fastapi import APIRouter
|
|
from fastapi import UploadFile
|
|
import os
|
|
|
|
upload = APIRouter()
|
|
|
|
|
|
@upload.post("/")
|
|
def upload_file(files: List[UploadFile]):
|
|
paths = []
|
|
for file in files:
|
|
path = os.path.join("images", file.filename)
|
|
with open(path, "wb") as f:
|
|
for line in file.file:
|
|
f.write(line)
|
|
paths.append(path)
|
|
return paths
|