如何使用 Python FastAPI 从 PDF 获取缓冲区数据

问题描述 投票:0回答:0

我在 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文件中获取缓冲区数据,但我无法获取数据

python pdf buffer fastapi
© www.soinside.com 2019 - 2024. All rights reserved.