如何在 JSON 文件中包含其他文件?

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

API 的文档说我应该放入 Body Params:

  1. restaurant_token:(必填)字符串 -> Tiller 提供的 API 访问令牌
  2. provider_token:(必填)字符串 -> Tiller 提供的 API 访问令牌
  3. 库存:(必填)文件 -> 库存导入文件
  4. clear:(booleantrue) -> 是否删除现有项目

我的 POST 请求是:

https://app.tillersystems.com/api/inventory/import

我的 JSON 是:

{
    "provider_token": "xxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "restaurant_token": "xxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "inventory": "C://Mes Projets//N74_Interface_Sage_Tiller//Exe//Traitement//Articles_SAGE_20210826172848541.csv",
    "clear": true
}

请求的答案是:

{
    "import": false,
    "message": "Missing \"inventory\" file field."
}
json file
1个回答
0
投票

您可以将文件编码为 base64 并将其作为字符串,如 this

但我认为最好的解决方案是使用标准文件共享协议

要发送大文件,无论如何,您都必须以原始形式发送它们,而无需转换为 Base64。

要在客户端下载文件,您可以接收 json 格式的有关文件的数据,其中将包括生成的使用标准协议下载文件的链接。

© www.soinside.com 2019 - 2024. All rights reserved.