我试图通过httpx将数据发送到戈滕贝格容器。
r = httpx.post(
"http://doc-to-pdf:3000/forms/chromium/convert/html",
files={
"index.html": file_bytes,
},
params={
"marginTop": 0.4,
"marginBottom": 0.45, # 0.39 minimum for appending page number
"marginLeft": 0.1,
"marginRight": 0.1,
},
)但我错了
('Error from gotenberg, %r , %r', 400, b"Invalid form data: form file 'index.html' is required")知道为什么没有通过httpx传递文件名吗?
发布于 2022-07-21 14:47:28
https://www.python-httpx.org/quickstart/搜索“发送多部分文件上载”
>>> files = {'{file}': open('report.xls', 'rb')}
>>> r = httpx.post("{url}", files=files)
>>> print(r.text)
{
...
"files": {
"{file}": "<... binary content ...>"
},
...
}
Where {file} is the name of field in your {url}-endpoint schema
i.e:
@router.post({url})
def test_file(
{file}: UploadFile
):
passhttps://stackoverflow.com/questions/72936206
复制相似问题