I am using Java jersey Restful service running on Tomcat server... In my service i have a method like this
@Produces("text/plain")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadFile(
@FormDataParam("file") InputStream fileInputStream,
@HeaderParam("Filename") String Filename) {
String uploadedFileLocation = "D://FileUpload/" + Filename;
ImageUpload filewrite = new ImageUpload();
}
But I am getting the error
Missing dependency for method public javax.ws.rs.core.Response Restservice_Java.Hello.uploadFile(java.io.InputStream,java.lang.String) at parameter at index 0
Can anyone help me in this..
hi you should always respond with Response :
@Produces("text/plain")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadFile(
@FormDataParam("file") InputStream fileInputStream,
@HeaderParam("Filename") String Filename) {
String uploadedFileLocation = "D://FileUpload/" + Filename;
ImageUpload filewrite = new ImageUpload();
// if(error==true) return Response.status(400).build();
return Response.ok().entity("job done").build();
}
The object Response can return a http w3C status code and a message with .entity("example")
. See the Response - jersey doc
Enjoy jersey ! give me some feedbacks please . :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.