I have a meteorJS app; where I am creating a read stream of an image and along with that and posting that information to a REST end point written in Java 8.
The meteor server side code looks like
var attachments = {},
request = require('request');
fs = require('fs-extra');
attachments.push({
value: fs.createReadStream("C:/temp/testImage.jpg"),
options: {
title: 'Test Image'
}
});
var formData = {
assets: attachments[0]
};
request.post({url: _restURL, formData: formData}, function optionalCallback(err, httpResponse, body) {
if (err) {
console.log("upload failed", err);
} else {
console.log("upload successful");
}
On the Java side, the code looks like
@RequestMapping(method = RequestMethod.POST, consumes="multipart/form-data, path="/fileupload")
public ResponseEntity<?> createFile(@PatnVariable("userId") String userId, @PathVariable("companyId") String companyId, @RequestBody MultipartFile[] assets) {
//Code to save the file to DMZ
...
}
Now the problem is, I cannot seem to get the title information on the server side.
I used the information provided on https://github.com/request/request#forms to populate formData