1

I am trying to upload a file using jar-rs and postman.

  @POST  
  @Path("/upload")  
  @Consumes(MediaType.MULTIPART_FORM_DATA)  
  public Response uploadFile( @DefaultValue("true") 
            @FormDataParam("enabled") boolean enabled,
            @FormDataParam("file") InputStream uploadedInputStream,
            @FormDataParam("file") FormDataContentDisposition fileDetail) {


        String uploadedFileLocation = "D://uploadedFiles/" + 
                                                fileDetail.getFileName();
        System.out.println(uploadedFileLocation);
}

But while excuting webservice I am getting fileDetail parameter as null.
Why it is null?

6
  • You have mapped the same parameter to two variables here i.e uploadedInputStream & fileDetail. @FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataContentDisposition fileDetail Commented May 15, 2018 at 10:30
  • Please check this link: stackoverflow.com/a/25889454/540195 Commented May 15, 2018 at 10:35
  • In refererence example they have also given same name Commented May 15, 2018 at 10:35
  • @Amit I have refered same link Commented May 15, 2018 at 10:36
  • what about your request code? You have to send exact same name "file" MultipartEntity reqEntity = new MultipartEntity(); reqEntity.addPart("file", fileContent); Commented May 15, 2018 at 10:40

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.