[英]How send array in fileTransfer option object in ionic 2
I want to save the image using fileTransfer in Ionic 2.我想在 Ionic 2 中使用 fileTransfer 保存图像。
How to send array
in fileTransfer
object.如何在
fileTransfer
对象中发送array
。 I didn't get it on the server side.我没有在服务器端得到它。
var options = {
fileKey: "file",
fileName: filename,
chunkedMode: false,
mimeType: "image/jpg",
headers : {},
params: {
'file': filename,
'rId': this.rId,
'model':{ 'RId': this.rId }
}
};
const fileTransfer: TransferObject = this.transfer.create();
fileTransfer.upload(targetPath, url, options).then(data => {
console.log(data);
}, err => {
console.log("Upload Err : "+ err);
});
}
Here at server side rId
and file values are getting but model is not displaying any value.在服务器端
rId
和文件值正在获取,但模型未显示任何值。
Try converting the object to JSON and then sending it in the model parameter and then on the server side, use JSON decode method to get the original object.尝试将对象转换为 JSON,然后将其发送到模型参数中,然后在服务器端使用 JSON 解码方法获取原始对象。
eg例如
var modelObj = JSON.stringify({ 'RId': this.rId });
var options = {
fileKey: "file",
fileName: filename,
chunkedMode: false,
mimeType: "image/jpg",
headers : {},
params: {
'file': filename,
'rId': this.rId,
'model': modelObj
}
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.