I am trying to create a Confluence rest Plugin which offers the possibility to upload a file to the server,. currently I am using atlas-run for testing.
My attempts to use parts of the many samples on how to achieve this with jax-rs and jersey,
didnt work out with fulfilling the packaging dependencies.
@FormDataParam seems to need jersey-multipart package:
using this in my pom.xml, leads to more needed com.sun.packages and ongoing “missing requirements” messages like missing requirement [261.0] osgi.wiring.package; (osgi.wiring.package=com.sun.net.server) and more …
@Override
@Path("/somepath")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@POST
public Response requestDevice(@Context HttpServletRequest request){
List<FileItem> items = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(request);
for (FileItem item : items) {
// Parse the form file here
if (!item.isFormField()) {
}
else {}// Parse the form data here
}
...}
The xsrf is answered in your other question. The override annotation is a leftover from copy paste please ignore. And yes it aligns with the rest entry in the xml. You can also explicitly ignore the lack of xsrf token using some annotation which i cant remember atm
additionally apache.commons fileupload package also needs to be added, which itself needs javax.portlet.
it is a miracle how this all works with all those packages, dependencies,spring beans, modules, annotations … sometimes it feels like rocket science to me