I need to pass file with formdata and server written in java should receive as below
public Response uploadFileWithMetadata(ObjectMetadata objectMetadata, MultipartBody multipartBody) {}
below is the client code and I am passing which is sending as objectMetadata as null and multipartBody array has 2 values, one with file and other with objectMetadata and that is not accepted by service as valid input. ObjectMetadata received on the server side should be application/json and I set that in the formdata. But that is received as text/plain and I am suspecting, that is causing issue
var options = {
method: 'POST',
uri: url,
formData: {
objectMetadata: {value: JSON.stringify(inputToPass),options:{'Content-Type': 'application/json'}},
file1: fs.createReadStream('/Users/mohansee/Desktop/Node_drekar_setup.docx')
}
};
rp(options)
.then(function (body) {
console.log('inside success'); console.log(body)
}) .catch(function (err) {
console.log('inside error');
console.log(err);
});
Please check and let know if I am missing something in the data section that need to be passed as separate parameter