multipart/form-data:当需要在表单中上传文件时,需要使用正确的格式:fromfastapiimportFastAPI,File,Form,UploadFileapp=FastAPI()@app.post("/files/")asyncdefcreate_file(file:bytes=File(...),fileb:UploadFile=File(...),token:str=Form(...),name:str=Form(...)):return{"file_size":len(file),"token":token,"fileb_content_type":fileb.content_type,}注意:根据HTTP协议,由于上传文件需要上传文本,这段文字如果是form,不是json参考文章:ImportFileandFormHTTPcontent-type
