提出错误的问题,请参阅下面的更新
我需要将我的AngularJS项目与现有的RESTful API集成.这些API使用POST请求upload a file,并在请求中提交表单数据.不幸的是,其中一个表单输入需要进入Content-Type: Application/json.
在网络上搜索后,我只能POST跟Content-Type: multipart/form-data其中每个部分不具有特定的MIME.如何 在Javascript中为每个部分组合我multipart/form-data的不同MIME?
POST /api/v1/inventory
Host: localhost:8000
Origin: http://localhost:9000
Content-Type: multipart/form-data; boundary=------border
------border
Content-Disposition: form-data; name="owner"
john doe
------border
Content-Disposition: form-data; name="image"; filename="mybook.png"
Content-Type: image/png
------border
Content-Disposition: form-data; name="items"
Content-Type: application/json
{"name": "Book", "quantity": "12"}
------border--
Run Code Online (Sandbox Code Playgroud)
相关参考文献:
为提出错误的问题而道歉.最初的问题是,我可以看到服务器调用逻辑的东西,
func POST(req):
owner = req.owner // This is string
image = req.image …Run Code Online (Sandbox Code Playgroud)