Announcement Announcement Module
Collapse
No announcement yet.
Question on ResponseBody as a parameter Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Question on ResponseBody as a parameter

    I am making a restful POST call to my controller where the contents sent to my method will be the contents of the PDF data.
    Code:
    @RequestMapping(value = "{param1}", method = RequestMethod.POST)
    	public void getData(@PathVariable("param1") String param1, @RequestBody byte[] b) throws Exception {
    		
    		try {
    		OutputStream output = null;
    		try {
    		
    		output = new BufferedOutputStream(new FileOutputStream("some.pdf"));
    		output.write(b);
    		}
    		finally {
    			output.close();
    		}
    		}
    		catch(Exception ex) {
    			ex.printStackTrace();
    		}
    		
    
    	}
    My problem is that when i use to make a post request via curl for sending pdf contents to my method, it process but creates a corrupted PDF file. Any idea or help will be great..

    curl -X POST -d @/home/foo/Downloads/pdfSample.pdf http://localhost:8080/foo/ddd

  • #2
    Solved my own question

    Comment

    Working...
    X