I am need to pass file with metadata and I followed the way mentioned in documentation
Client nodejs-
unirest.post(url)
.auth({user:'username', pass:'pwd'})
.header({'Content-Type': 'multipart/form-data'})
.field('objectMetadata', JSON.Stringify(json obj))
.field("file1", fs.createReadStream("setup.docx"))
.then(function (response) {
console.log(response.body)
});
Server - Java based
public Response uploadFileWithMetadata(ObjectMetadata objectMetadata, MultipartBody multipartBody) {}
In the server user says he see objectMetadata object as null and in multipartBody he sees 2 atts - one for file and other for objectmetadata. Same server works for unirest java and I tweaked the metadata part as below
I am need to pass file with metadata and I followed the way mentioned in documentation Client nodejs- unirest.post(url) .auth({user:'username', pass:'pwd'}) .header({'Content-Type': 'multipart/form-data'}) .field('objectMetadata', JSON.Stringify(json obj)) .field("file1", fs.createReadStream("setup.docx")) .then(function (response) { console.log(response.body) }); Server - Java based public Response uploadFileWithMetadata(ObjectMetadata objectMetadata, MultipartBody multipartBody) {}
In the server user says he see objectMetadata object as null and in multipartBody he sees 2 atts - one for file and other for objectmetadata. Same server works for unirest java and I tweaked the metadata part as below
.field("objectMetadata", params, false, "application/json")
Please let me know if I am missing something in the node based svc call
after retries, I need below snippet java equivalent in nodejs
.field(name, value, file, contentType)