0

this is my java rest api code

@POST
@Path("{imageTitle}/uploadPic")
@Produces("text/plain")
public Response uploadPic(Reader PicFile,
        @PathParam("imageTitle") String imageTitle) {

    String uploadPath = "/home/dev/";

    //What is next..????

}

how to create a file using reader input?

6
  • 2
    In Java, Reader and its subclasses are for reading text files. Since Images are stored in binary files, you really should be using an InputStream Commented Jul 30, 2015 at 11:57
  • possible duplicate of File Upload using Rest API in Java Commented Jul 30, 2015 at 11:57
  • 1
    see also javatpoint.com/jax-rs-file-upload-example Commented Jul 30, 2015 at 11:59
  • Make use of ImageIO to create a image in stream Commented Jul 30, 2015 at 12:04
  • also, you probably want to use a POST request and not GET, but maybe I misunderstood what you are trying to achieve? Commented Jul 30, 2015 at 12:06

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.