Hello, pretty new to java so bear with me.
I am trying to write an image over an HttpURLConnection.
I have an example of how to write text but I am having real problems trying
to write an image, just can't get my head around it.
I have succeeded in writing to the local HD using ImageIO:
//start image output
FileOutputStream fo = new FileOutputStream("myImg.jpg");
BufferedOutputStream bo = new BufferedOutputStream(fo);
ImageIO.write(destination, "jpeg", bo);
bo.close();
//end image output
This works a treat. I understand how to set up an url connection and then
write text to it:
//start text to url
URL url = new URL( "http://www.myurl.com/myfolder/aFile.cfm" );
HttpURLConnection urlcon = (HttpURLConnection) url.openConnection( );
urlcon.setRequestMethod("POST");
urlcon.setRequestProperty("Content-type",
"application/x-www-form-urlencoded");
//image/jpeg
urlcon.setDoOutput(true);
urlcon.setDoInput(true);
PrintWriter pout = new PrintWriter( new
OutputStreamWriter(urlcon.getOutputStream( ), "8859_1"), true );
pout.print( formData );//form data collected from app
pout.flush( );
// end text to url
What I am having a problem with is this bit:
PrintWriter pout = new PrintWriter( new
OutputStreamWriter(urlcon.getOutputStream( ), "8859_1"), true );
Where I want to put in my buffered output stream, and then use that with
ImageIO, I just can't see where I am supposed to start.... or have I missed
the boat entirely
Thanks for taking the time to read this post.
cheers
Martin
Thanks for your time
--
---------------
http://www.nonstoploop.co.uk/ - dynamic websites
http://www.rossanobacchin.be/ - fine art
http://www.weycameras.co.uk/ - photographic supplies
---------------