javascript - 用 JavaScript 读取 PDF 文件并通过 API 发送数据
问题描述
我基本上是在 JS 中寻找与此 Python 代码等效的功能:
它读取 pdf 文件并通过 Post 请求发送字节
from requests import get, post
source = "my_pdf.pdf"
with open(source, "rb") as f:
data_bytes = f.read()
post_url = "my_url"
resp = post(url = post_url, data = data_bytes)
目前我正在使用 react-jsonschema-form 库,该库具有从以下代码读取/加载文件的选项:
{
"title": "Files",
"type": "object",
"properties": {
"file": {
"type": "string",
"format": "data-url",
"title": "Single file"
}
}
}
上面的 json 模式生成这种形式:
有了它,我可以从我的计算机加载文件:
但是从这里开始,我不知道如何将数据发送到 API
解决方案
推荐阅读
- c++ - 从 Rcpp Catch 测试中访问 `inst/extdata` 的数据
- c# - 通过代理时连接超时
- android - NotifyItemRangeInserted 不会触发要回收的视图
- amazon-web-services - DynamoDBMapper 有条件地保存对象列表
- php - ACF 设置图库缩略图自定义大小
- javascript - 单击文档时如何关闭菜单(EventListener)
- php - 激活购买的主题时,Wordpress 管理员中断
- android - [[15.0.1,15.0.1]] 的各种其他库正在请求库 com.google.android.gms:play-services-base,但解析为 16.0.1
- r - `%between%` (data.table) 给了我一个奇怪的结果
- python - 无频率不允许seasonal_decompose