You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Eric Mckenna <er...@phase2technology.com> on 2004/03/09 02:17:20 UTC
Having Trouble with MultipartPostMethod
Greetings,
Having some trouble with transferring a file to another server.
Here's the flow:
User submits excel doc to ServerA
ServerA get post, creates MultipartPost and posts to ServerB.
ServerB saves the file received, but when opened the encoding is all wrong.
The data is there but "No Alderan"
Submitting the file directly to ServerA or ServerB is fine. The file can be
read by excel. From what I can tell,
I'm doing something incorrectly with creation of the MultipartPost before
transmission to the other server.
Here's some code of what I'm doing:
MultipartPostMethod method = new MultipartPostMethod(buildURL(getPath()));
method.setFollowRedirects(false);
...
...
MultiPartRequestWrapper request =
ServletActionContext.getMultiPartRequest();
fileForUpload = request.getFile(FILENAME_FIELD);
FilePart p = new FilePart(fileForUpload.getName(), fileForUpload,null,
null);
p.setTransferEncoding(null);
method.addPart(p);
ServerA is IIS:Tomcat 4.1.29
SeverB is WebLogic8.1
jdk 1.4.1
Thanks,
eric.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
Re: Having Trouble with MultipartPostMethod
Posted by Eric Mckenna <er...@phase2technology.com>.
Ok., I fixed the problem, I needed to setHttp() to true and the additional
params for FilePart were not necessary for my needs.
FilePart p = new FilePart(FILENAME_FIELD, fileForUpload);
p.setTransferEncoding(null);
method.setHttp11(true);
method.addPart(p);
----- Original Message -----
From: "Eric Mckenna" <er...@phase2technology.com>
To: <co...@jakarta.apache.org>
Sent: March 08, 2004 8:17 PM
Subject: Having Trouble with MultipartPostMethod
> Greetings,
>
> Having some trouble with transferring a file to another server.
>
> Here's the flow:
> User submits excel doc to ServerA
> ServerA get post, creates MultipartPost and posts to ServerB.
> ServerB saves the file received, but when opened the encoding is all
wrong.
> The data is there but "No Alderan"
>
> Submitting the file directly to ServerA or ServerB is fine. The file can
be
> read by excel. From what I can tell,
> I'm doing something incorrectly with creation of the MultipartPost before
> transmission to the other server.
> Here's some code of what I'm doing:
>
> MultipartPostMethod method = new MultipartPostMethod(buildURL(getPath()));
> method.setFollowRedirects(false);
> ...
> ...
> MultiPartRequestWrapper request =
> ServletActionContext.getMultiPartRequest();
> fileForUpload = request.getFile(FILENAME_FIELD);
> FilePart p = new FilePart(fileForUpload.getName(), fileForUpload,null,
> null);
> p.setTransferEncoding(null);
> method.addPart(p);
>
> ServerA is IIS:Tomcat 4.1.29
> SeverB is WebLogic8.1
> jdk 1.4.1
>
>
> Thanks,
> eric.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
commons-httpclient-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
Re: Having Trouble with MultipartPostMethod
Posted by Michael Becke <be...@u.washington.edu>.
I believe it's because older versions of FileUpload cannot handle the
transfer-encoding and/or content-type multi-part headers. These can be
removed by setting them to null on the FilePart.
Mike
Ortwin Glück wrote:
>
>
> Eric Mckenna wrote:
>
>> sorry ;), It's a reference to Star Wars.
>
>
> :-)
>
>> I can open the transferred file and view the file, but the data is in
>> a raw
>> or Hex form. I'm not sure what form exactly, but i went ahead and
>> attached
>> an example.
>
>
> Eric,
>
> It looks like there is an extra CR LF at the beginning of your Excel
> file. I assume you are using Commons FileUpload on the server side. We
> have had this problems before. It seems that FileUpload fails to parse
> Multipart MIME correctly depending on the headers of the MIME part. I
> can't remember what was done to solve this, but you might want to search
> the email archive of this list to find the solution or ask the guys over
> at FileUpload.
>
> Cheers
>
> Ortwin Glück
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> commons-httpclient-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
Re: Having Trouble with MultipartPostMethod
Posted by Ortwin Glück <or...@nose.ch>.
Eric Mckenna wrote:
> sorry ;), It's a reference to Star Wars.
:-)
> I can open the transferred file and view the file, but the data is in a raw
> or Hex form. I'm not sure what form exactly, but i went ahead and attached
> an example.
Eric,
It looks like there is an extra CR LF at the beginning of your Excel
file. I assume you are using Commons FileUpload on the server side. We
have had this problems before. It seems that FileUpload fails to parse
Multipart MIME correctly depending on the headers of the MIME part. I
can't remember what was done to solve this, but you might want to search
the email archive of this list to find the solution or ask the guys over
at FileUpload.
Cheers
Ortwin Glück
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
Re: Having Trouble with MultipartPostMethod
Posted by Eric Mckenna <er...@phase2technology.com>.
sorry ;), It's a reference to Star Wars.
I can open the transferred file and view the file, but the data is in a raw
or Hex form. I'm not sure what form exactly, but i went ahead and attached
an example.
----- Original Message -----
From: "Ortwin Gl�ck" <or...@nose.ch>
To: "Commons HttpClient Project" <co...@jakarta.apache.org>
Sent: March 09, 2004 3:54 AM
Subject: Re: Having Trouble with MultipartPostMethod
> Eric Mckenna wrote:
> > but when opened the encoding is all wrong.
> > The data is there but "No Alderan"
>
> Could you be more specific about this please? What do you mean?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
commons-httpclient-dev-help@jakarta.apache.org
>
Re: Having Trouble with MultipartPostMethod
Posted by Ortwin Glück <or...@nose.ch>.
Eric Mckenna wrote:
> but when opened the encoding is all wrong.
> The data is there but "No Alderan"
Could you be more specific about this please? What do you mean?
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org