0

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..

Alexey Malev
  • 6,408
  • 4
  • 34
  • 52
Wilson
  • 176
  • 1
  • 11

1 Answers1

0

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 . :)

jeorfevre
  • 2,286
  • 1
  • 17
  • 27
  • Jean u have any idea abt this http://stackoverflow.com/questions/24054200/sending-large-image-in-chunks – Wilson Jun 06 '14 at 04:50