I'm not sure if this will help you, but here is what I did to get it working. There was a hidden field in the html form that was required with the uploaded file, I simply moved the field from the form to the url.
The form had this as a field <input type="hidden" name=curDir" /> And added it to the URL like this: https://www.angel.com/AudioManager?command=upload&FullSizeManager=true&curDir=/ You can add additional parameters to the url as needed. Here is the code I used to upload the file: private static final String ANGEL_UPLOAD_URL = " https://www.angel.com/AudioManager?command=upload&FullSizeManager=true&curDir=/ "; PostMethod multiPartPost = new PostMethod( ANGEL_UPLOAD_URL + siteName ); PartSource partSource = new ByteArrayPartSource( fileName, fileBytes ); FilePart filePart = new FilePart( "file2", partSource ); filePart.setTransferEncoding( null ); Part[] parts = new Part[]{ filePart }; multiPartPost.setRequestEntity( new MultipartRequestEntity( parts, multiPartPost.getParams() ) ); httpClient.executeMethod( multiPartPost ); On 8/3/07, Quan Qiu <[EMAIL PROTECTED]> wrote: > > Hello James > > Do you mind to share your codes of uploading files by adding a parameter > on > the URL with a hidden field multipart form? > > Thanks > Quan > > > On 7/9/07, James Norman <[EMAIL PROTECTED]> wrote: > > > > Just an FYI for anyone who may run across this thread. I just got it > > working, what I did was the recommended PartBase.setTransferEncoding( > > null ) as well as move an additional StringPart from the part array to > > a parameter on the URL. There was a hidden field in the multipart > > form and I just moved it to the URL. This way I had only FilePart > > parts in the multipart request. Thanks to all for the help. > > > > -james > > > > On 7/5/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > Sorry about that (sent before finished) > > > > > > As I was saying, > > > For our situation, we needed to set both: > > > > > > Partbase.setTransferEncoding( null ) AND > > > Partbase.setConentType(null) for each part, then it worked. > > > > > > Hope that helps, > > > Dave > > > > > > -----Original Message----- > > > From: Bantel, Dave (TTA R&G) > > > Sent: Thursday, July 05, 2007 8:08 AM > > > To: 'HttpClient User Discussion' > > > Subject: RE: Multipart post error > > > > > > James, > > > > > > We had a similar issue with multipart posts - we were able to get it > to > > > work using cURL (which we use for a legacy app), then we compared the > > > trace from both requests. For our situation, we needed to set both > > > Partbase.setTransferEncoding( null ) AND > > > > > > > > > > > > > > > -----Original Message----- > > > From: James Norman [mailto:[EMAIL PROTECTED] > > > Sent: Wednesday, July 04, 2007 5:16 PM > > > To: HttpClient User Discussion > > > Subject: Re: Multipart post error > > > > > > I was afraid that was the answer I would get. I haven't done any > packet > > > analysis for a while, what tool would you recommend for Windows? > > > > > > Also, are there any applications such as wget that would support > > > multipart posts? > > > > > > -james > > > > > > On 7/4/07, Oleg Kalnichevski <[EMAIL PROTECTED]> wrote: > > > > On Tue, 2007-07-03 at 22:32 -0600, James Norman wrote: > > > > > Hey All, > > > > > I'm not sure if anyone will be able to help with this but I > figured > > > > > I'd try. I'm trying to post multipart/form-data through > httpclient > > > > > and I'm receiving the following exception on the server: > > > > > > > > > > java.io.IOException: Malformed line after content type: > > > > > Content-Transfer-Encoding: 8bit > > > > > > > > > > I get this in the stacktrace that is provided from the response on > > > > > the server. I don't have access to code that runs on the server > and > > > > > > > > it just happened to be running java and printed the stack > trace. It > > > > > > > > also appears to be running some proprietary multipart server code, > > > > > this was in the stack: > > > > > at > > > > > com.mstr.sound.MultipartRequest.readNextPart(MultipartRequest.java > :2 > > > > > 31) > > > > > > > > > > I have been successful uploading files with HttpClient and Tomcat > > > > > locally, but not on this remote server. > > > > > > > > > > I found this thread from someone who had the same exception: > > > > > > http://mail-archives.apache.org/mod_mbox/jakarta-httpclient-user/200 > > > > > 512.mbox/[EMAIL PROTECTED] > > > > > Which had a recommended solution to > > > > > Partbase.setTransferEncoding( null ); However this did not fix the > > > > > issue and the server started returning NPEs. > > > > > > > > > > My question is this, the file upload works fine through Firefox > and > > > > > IE but does not work through HttpClient, does anyone have any > > > > > suggestions I can try. I'm also open to any workaround, even > > > > > shelling to another program to get this working. > > > > > > > > > > Thanks for any help you can provide. > > > > > > > > > > > > > James, > > > > > > > > Here's what you may want to try: > > > > > > > > (1) capture packets generated by IE or Firefox using a traffic > > > > analyzer or a proxy > > > > (2) capture packets generated by HttpClient > > > > (3) compare the composition of the multipart requests > > > > (4) try to eliminate differences in the generated requests by > tweaking > > > > > > > HttpClient's configuration / subclassing MultipartRequestEntity. > > > > > > > > Hope this helps > > > > > > > > Oleg > > > > > > > > > -james > > > > > > > > > > > -------------------------------------------------------------------- > > > > > - To unsubscribe, e-mail: > > > > > [EMAIL PROTECTED] > > > > > For additional commands, e-mail: > > > > > [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > To unsubscribe, e-mail: > [EMAIL PROTECTED] > > > > For additional commands, e-mail: > > > > [EMAIL PROTECTED] > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: > [EMAIL PROTECTED] > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: > [EMAIL PROTECTED] > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > >
