Image writing over URLConnection

 
 

Share on Google+Share on Google+

dilip agarwal
Image writing over URLConnection
0 Answer(s)      6 years and 10 months ago
Posted in : Java Beginners

Hello, I am trying to write an image over an HttpURLConnection.

I know how to write text but I am having real problems trying to write an image

I have succeeded in writing to the local HD using ImageIO:

But I am trying to write Image by ImageIO on url and failed

URL url = new URL(uploadURL); connection = (HttpURLConnection) url.openConnection(); connection.setDoOutput(true); connection.setRequestMethod("POST"); connection.setDoInput(true); connection.setUseCaches(false); connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary); output = new DataOutputStream(connection.getOutputStream()); output.writeBytes("--" + boundary + "\r\n"); output.writeBytes("Content-Disposition: form-data; name=\"" + FIELD_NAME +

"\"; filename=\"" + fileName + "\"\r\n");

output.writeBytes("Content-Type: " + dataMimeType + "\r\n"); output.writeBytes("Content-Transfer-Encoding: binary\r\n\r\n"); ImageIO.write(image, imageType, output);

the uploadURL is the url to an asp page on the server which will upload the image with the file name given in "content-Disposition: part.

now when I send this then asp page find the request and find the name of file. but does not find the file to be uploaded.

The problem is that when writing by ImageIO on URL what will the name of the file on which the ImageIO is writing,

So please help me how ImageIO will write an image on URLConnection and how can I know the name of the file which I have to use in the asp page to upload the file

Thanks for taking the time to read this post Dilip Agarwal

Thanks for your time

Ads
View Answers
Ads









Related Tutorials/Questions & Answers:
Image writing over URLConnection
Image writing over URLConnection  Hello, I am trying to write an image over an HttpURLConnection. I know how to write text but I am having real problems trying to write an image I have succeeded in writing to the local HD using
Image swap on mouse over and mouse move
Image swap on mouse over and mouse move  i tried the code , sent form u...But if there are 50 images and..i want swap images on mousse over and mouse out, then the code becomes very lengthy...so please give the code for multiple
Advertisements
Image swap on mouse over and mouse move
Image swap on mouse over and mouse move  i tried the code , sent form u...But if there are 50 images and..i want swap images on mousse over and mouse out, then the code becomes very lengthy...so please give the code for multiple
How to access the image file from project folder itself while writing to pdf using itext?
How to access the image file from project folder itself while writing to pdf using itext?  I am writing a pdf using itext where i add a image in the beginning of the document. When i use image = Image.getInstance("C
Print the URL of a URLConnection
Print the URL of a URLConnection       In this section we are going to describe, how to retieve... that we use the getURL() which returns the value of this URLConnection's URL field
Version of com.jdroidframework>jdroid-java-http-urlconnection dependency
List of Version of com.jdroidframework>jdroid-java-http-urlconnection dependency
Open a URLConnection to specific website address
Open a URLConnection to specific website address       Here we are going to establish... of URLConnection. After that we put the try and catch block and assign a URL
image
image  how to add the image in servlet code
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
image
image   Dear every body please help me how to add and retrive image and video into oracle 11g using jsp
Ghost Writing
Ghost Writing Ghost Writing is the kind of writing when someone... of writing it. So ghostwriter is a person who works behind the scene on a writing project in return of certain amount. The write-ups of the writer
Maven Dependency jdroid-java-http-urlconnection >> 0.8.0
You should include the dependency code given in this page to add Maven Dependency of com.jdroidframework >> jdroid-java-http-urlconnection version0.8.0 in your project
Maven Dependency jdroid-java-http-urlconnection >> 0.9.0
You should include the dependency code given in this page to add Maven Dependency of com.jdroidframework >> jdroid-java-http-urlconnection version0.9.0 in your project
Maven Dependency jdroid-java-http-urlconnection >> 0.9.1
You should include the dependency code given in this page to add Maven Dependency of com.jdroidframework >> jdroid-java-http-urlconnection version0.9.1 in your project
writing characters
writing characters  how to write a group of characters to a string ... i mean for writing single character using charAt in java
SEO Writing
is the demand of SEM and SEO article writing services. A good command over... with the changing algorithm of search engines. Our expertise over writing SEM articles...SEM and SEO Article Writing SEM and SEO article helps your business to grow
method over riding
method over riding  write a java program to compute volume of sphere and volume of cylinder using method over riding
mouse over effects in css
mouse over effects in css  I have written a mouse over effect in CSS. But it is not working in HTML. Can any one suggest me? Thanks
Call UIViewController over RootViewController
Call UIViewController over RootViewController   Hi, i have created the window based application.. but not sure how to call the UIView over RootViewController. Thanks
Blog Writing
Blog Writing A blog, the short form of web log is an online user... on that. But the professionals are a better choice for writing the blog for commercial or promotional purpose. We provides the services of writing blogs for the commercial
Data over Voice Communication
Data over Voice Communication  I just Want to know that Data Over Voice communication is possible in India or Not, If not then Why. and If Yes then Why Please anyone give the answer
application over https
application over https   Hi. This questions might be very simple but I would like to create a simple servlet program and want to access using https... while accessing https over http
hibernate over Jdbc
hibernate over Jdbc  Why use hibernate over Jdbc?   Hibernate provides lots of advantages over JDBC. Some of them are as below: 1) Hibernate is data base independent 2) Hibernate provides its own query language called
Writing Actions
Writing Actions The Action is responsible for controlling of data flow within an application. You can make any java class as action. But struts have some built in interface and class for making action easily. To make an Action class
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks

Ads

 
Advertisement null

Ads