Hello All,
2004. m�rcius 4. 14.47 d�tummal [EMAIL PROTECTED] ezt �rta:
> take a look here
>
> http://wiki.cocoondev.org/Wiki.jsp?page=RecipeUploadUsingAction
>
> it working
Thanks a lot, it working really.
I use it in Linux and my context is my home directory, link is:
server/cocoon/~zamek/app/
I cannot pass it to Fileupload. I think I try to pass cocoon:/ but it doesn
�t works.
I modified your code to accept cocoon:/ protocoll:
declarations section:
/* cocoon:/ */
private static final String COCOON_ENTRY = "cocoon:/";
private final static String FILE_ENTRY = "file:";
and act method:
originally:
if (req instanceof HttpRequest) {
HttpRequest request = (HttpRequest) req;
/* create necessary directory structure */
File uplDir = new File(parUploadDirectory);
if (isDebugEnabled) {
myLogger.debug(
"upload directory is: " +
uplDir.getAbsolutePath());
}
if (uplDir.isAbsolute() == false) {
// check for first relative slash
if (parUploadDirectory.indexOf('/') != 0) {
parUploadDirectory = "/" + parUploadDirectory;
}
uplDir = new
File(context.getRealPath(parUploadDirectory));
}
if (isDebugEnabled) {
myLogger.debug(
"absolute upload directory is: "
+ uplDir.getAbsolutePath());
}
modified:
if (req instanceof HttpRequest) {
HttpRequest request = (HttpRequest) req;
/* create necessary directory structure */
File uplDir = new File(parUploadDirectory);
if (isDebugEnabled) {
myLogger.debug(
"upload directory is: " +
uplDir.getAbsolutePath());
}
if (parUploadDirectory.startsWith(COCOON_ENTRY) ) {
parUploadDirectory =
parUploadDirectory.substring(COCOON_ENTRY.length());
Source inputSource = resolver.resolveURI("");
String sysId = inputSource.getURI();
sysId = sysId.substring(new
String(FILE_ENTRY).length());
uplDir = new File (sysId+parUploadDirectory);
}
else {
if (uplDir.isAbsolute() == false) {
// check for first relative slash
if (parUploadDirectory.indexOf('/') != 0) {
parUploadDirectory = "/" +
parUploadDirectory;
}
uplDir = new
File(context.getRealPath(parUploadDirectory));
}
}
if (isDebugEnabled) {
myLogger.debug(
"absolute upload directory is: "
+ uplDir.getAbsolutePath());
}
and need to import
import org.apache.excalibur.source.Source;
in sitemap you can use:
<map:match pattern="upload-*">
<map:act type="file-upload-action">
<map:parameter name="number-of-files" value="1"/>
<map:parameter name="file-form-field-prefix"
value="upload-file"/>
<map:parameter name="upload-directory"
value="cocoon:/{request-param:upload-dir}"/>
<map:parameter name="overwrite-file" value="rename"/>
--
thx,
----------------------------------------------------
Zoltan Zidarics programmer
PTE University Pecs, Hungary
icq: 43288694
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]