我在 FastAPI 中读取 pdf 文件数据时遇到错误
代码:
from fastapi import FastAPI, Depends, HTTPException, UploadFile
app = FastAPI()
@app.post('/')
async def storeFileData(file:UploadFile):
content = file.file.read()
return {"ok":True,"content":content}
错误:UnicodeDecodeError:“utf-8”编解码器无法解码位置 10 中的字节 0xe2:无效的连续字节
我尝试使用上面的代码从pdf文件中获取缓冲区数据,但我无法获取数据