You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by Stefan Groschupf <sg...@media-style.com> on 2003/08/04 15:37:30 UTC
fileupload
Hi incites, ;)
I want to test file upload with strutsTestCase.
I found this link.
http://jakarta.apache.org/cactus/faq.html#faq7
Since the link to the httpclient is dead and I can't find a other download
location can someone provide me the hhtpclient package from Ronald Tschal�r?
Is this package related to the apache httpclient?
Thanks
Stefan
Re: fileupload
Posted by Christopher Lenz <cm...@gmx.de>.
Stefan Groschupf wrote:
> Hi incites, ;)
>
> I want to test file upload with strutsTestCase.
> I found this link.
>
> http://jakarta.apache.org/cactus/faq.html#faq7
>
> Since the link to the httpclient is dead and I can't find a other download
> location can someone provide me the hhtpclient package from Ronald Tschalär?
The link works here.
> Is this package related to the apache httpclient?
No (it is sometimes referred to as the "innovation.ch HTTPClient").
But AFAIK Apache Commons-HttpClient also supports file upload. You might
prefer to use that because you should already have Commons-HttpClient on
your classpath.
http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/httpclient/methods/multipart/package-summary.html
--
Christopher Lenz
/=/ cmlenz at gmx.de
multi part
Posted by Stefan Groschupf <sg...@media-style.com>.
Hi there,
sorry i have still problems with testing uploading.
I steeled HttClient from an other project cvs. I take the code from the
cactus faq. I use an extension to catus: struststest 2.0.0.
I don't get an multi part request in my struts action, but can't see where
an mistake could be..
Someone can give an hint?
Thanks a lot!!!
Stefan
My code looks like:
NVPair[] hdrs = new NVPair[1];
public void beginCreateDocumente(org.apache.cactus.WebRequest theRequest) {
WetaSecurityManager.getInstance().setPrincipal(getSession(), new
Principal(ITestDatabaseEntries.CONTENT_ADMIN, "pw"));
LoginContext loginContext;
try {
// ... create some test data ...
File file1 = new File(System.getProperty("java.io.tmpdir") +
"/HttpUploadUtilsTest.dat");
// setup the file(s) name value pair object.
NVPair[] file = { new NVPair("binaryTypeAttribute",
file1.getAbsolutePath())};
form_data[0] = new NVPair(IParameterKeys.LOCALE, "en");
form_data[1] = new NVPair(IParameterKeys.NAME, "a test name");
form_data[2] = new NVPair(IParameterKeys.FOLDER_PK, "" + folderPK);
form_data[3] = new NVPair(IParameterKeys.XSLT, xslts[0]);
form_data[4] = new NVPair(IParameterKeys.TYPE_PK, "" + typePK);
byte[] data = Codecs.mpFormDataEncode(form_data, file, hdrs);
InputStream i = new ByteArrayInputStream(data);
theRequest.setUserData(i);
theRequest.setContentType(hdrs[0].getValue());
i.close();
loginContext.logout();
} catch (IOException e) {
System.out.println("Error Building Multipart");
} catch (LoginException e) {
System.err.println("error: " + e.toString());
} catch (CreateException e) {
System.err.println("error: " + e.toString());
} catch (NamingException e) {
System.err.println("error: " + e.toString());
} catch (FinderException e) {
System.err.println("error: " + e.toString());
} catch (RemoveException e) {
System.err.println("error: " + e.toString());
} catch (WetaDocumentException e) {
System.err.println("error: " + e.toString());
}
}
public void testCreateDocument() throws LoginException, FinderException,
RemoveException, CreateException, NamingException, WetaDocumentException {
setRequestPathInfo("/" + IActionKeys.CREATE_DOCUMENT);
verifyForward("Xslt");
assertEquals(getRequest().getAttribute("xslt"), "message");
assertTrue(getRequest().getAttribute("xml") instanceof Document);
}
RE: fileupload
Posted by Vincent Massol <vm...@pivolis.com>.
Hi Stefan,
You can also try http://www.freeroller.net/page/tradem/20030722. It
seems Tobias has succeeded in using Commons-httpclient to perform file
uploads with Cactus.
Thanks
-Vincent
> -----Original Message-----
> From: Stefan Groschupf [mailto:sg@media-style.com]
> Sent: 04 August 2003 15:38
> To: Cactus Users List
> Subject: fileupload
>
> Hi incites, ;)
>
> I want to test file upload with strutsTestCase.
> I found this link.
>
> http://jakarta.apache.org/cactus/faq.html#faq7
>
> Since the link to the httpclient is dead and I can't find a other
download
> location can someone provide me the hhtpclient package from Ronald
> Tschalär?
> Is this package related to the apache httpclient?
>
> Thanks
> Stefan
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org