Is there a specific example or way you suggest to handle a incoming HTTP post!? I am uploading a file (image) from the frontend and have written a working API Post route (localhost:9000/api/org.plugins.logo-replacer/uploadLogo). But I am having trouble allowing the function I created to parse the data. I do not want to have to include other resources such as HttpServlet jar. What would you recommend being the best way to consume a API Post call!?
Frontend Code:
_saveConfig(e) {
let data = this.refs.logoReplacerConfigModal.refs.form.elements[1].files[0];
let fd = new FormData();
fd.append('image', data);
this.props.updateConfig(this.state.config).then(() => {
fetch('http://localhost:9000/api/plugins/org.graylog.plugins.logo/uploadLogo', {
method: 'POST',
// headers: {
// 'Content-Type': 'multipart/form-data',
// },
body: fd
})
.then(function(response) {
console.log('success');
this._closeModal();
});
});
}
Backend Code:
@POST
@Timed
@ApiOperation(value = "Upload Logo")
@NoAuditEvent("only used to upload a new image to graylog")
public void upload(HttpServletRequest request) {
LOG.info("");
}