spring - multipartfile 可以用图像发送一些信息吗?
问题描述
我想用一些信息将 multipart/form-data 发送到 spring 服务器。但我不知道这是正确的方法。
a.push({ name: 'file', filename: this.state.fileName, data: RNFetchBlob.wrap(this.state.uri), desc: 'triptriptrip'});
this.setState({
images : a
})
});}
RNFetchBlob.fetch('POST', 'https://675c8a26.ngrok.io/appServer/postUpload/1', {
'Content-Type': 'multipart/form-data',
},this.state.images
)
我希望 spring 服务器获得“desc”信息,但服务器无法访问“desc”。如何访问该数据?
解决方案
如果要使用formdata
,请像这样使用它。
RNFetchBlob.fetch('POST','https://675c8a26.ngrok.io/appServer/postUpload/1',{
'Accept': 'application/json',
'Content-Type': 'multipart/form-data',
},
[
{ name: 'file', filename: this.state.fileName, data: RNFetchBlob.wrap(this.state.uri), desc: 'triptriptrip'},
]).then((response) => response.json())
.then((res) => {
console.log(res);
}).catch(err => {
console.log(err)
})
});
推荐阅读
- git - 如何解决“远程:您 (@user) 必须接受服务条款才能执行此操作。” 问题?
- apache-kafka - Kafka KStream OutOfOrderSequenceException
- reactjs - Jest 从依赖的 node_modules 抛出类型错误
- awk - 仅模式匹配字符串
- c# - 使用 IdentityServer4 进行子域多租户登录
- python - 在登录期间验证用户名和密码将用户返回为无
- cron - 如何每 2 分钟设置一次 cron,但仅从凌晨 12:00 开始设置 4 小时
- javascript - 如何在 JavaScript 中为特殊条件设置正则表达式?
- facebook - Facebook Marketing Api 错误:(#2635) 您正在调用已弃用的广告 API 版本。请更新到最新版本:v3.2。”
- android - 自动点击提交按钮以及如何通过提交按钮的时间限制?