[HtmlUnit] HtmlUnit Multipart file upload
Chander <[email protected]> Sun, 25 Oct 2020 22:20:43 -0500
| Newsgroups | gmane.comp.java.htmlunit.devel |
|---|---|
| Message-ID | <CADBS8H2vyjKXcuhdStLaWvEv1SjVr=5tcTsaukJAT__sXq3Syg@mail.gmail.com> |
--===============4803964712120679173==
Content-Type: multipart/alternative; boundary="0000000000002ddb9e05b28a6a35"
--0000000000002ddb9e05b28a6a35
Content-Type: text/plain; charset="UTF-8"
Hi,
I am using HtmlUnit to upload a file by making a request to the spring
controller. The file is of type MultipartFile. Using the below code works
only for File Type java.io.File. How do i make the call for MultipartFile?
WebRequest request = new WebRequest(new URL("/customer/uploadfile),POST);
request.setRequestParameters(toList(new KeyDataPair("newfile",
file,"customerfile", "multipart/form-data", StandardCharsets.UTF_8)));
I always receive Null inside the method for the file..
public ModelAndView uploadCustomerFile(ModelMap model,
RedirectAttributes redirect, @ModelAttribute MultipartFile file ) {
}
Please let me know..
Thanks for your time,
Chander
--0000000000002ddb9e05b28a6a35
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div dir=3D"ltr"><div>Hi,</div><div><br></div><div>I am us=
ing HtmlUnit to upload a file by making a request to the spring controller.=
The file is of type MultipartFile. Using the below code works only for Fil=
e Type java.io.File. How do i make the call for MultipartFile?</div><div><b=
r></div><div>WebRequest request =3D new WebRequest(new URL("/customer/=
uploadfile),POST);</div><div><br></div><div>request.setRequestParameters(to=
List(new KeyDataPair("newfile", file,"customerfile", &q=
uot;multipart/form-data", StandardCharsets.UTF_8)));</div><div><br></d=
iv><div>I always receive Null inside the method for the file..</div><div><b=
r></div><div>public ModelAndView uploadCustomerFile(ModelMap model,</div><d=
iv>=C2=A0RedirectAttributes redirect, @ModelAttribute MultipartFile file ) =
{=C2=A0</div><div><br></div><div>}</div><div>Please let me know..</div><div=
><br></div><div>Thanks for your time,</div><div>Chander</div></div></div>
--0000000000002ddb9e05b28a6a35--
--===============4803964712120679173==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
--===============4803964712120679173==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
HtmlUnit-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop
--===============4803964712120679173==--