org.apache.lenya.cms.authoring
Class UploadHelper

java.lang.Object
  extended by org.apache.lenya.cms.authoring.UploadHelper

public class UploadHelper
extends java.lang.Object

Helper class for uploading files.

Version:
$Id: UploadHelper.java 473842 2006-11-12 01:15:20Z gregor $
Author:
Andreas Hartmann , Michael Wechner

Constructor Summary
UploadHelper(java.io.File directory)
          Ctor.
UploadHelper(java.lang.String directoryPath)
          Ctor.
 
Method Summary
 boolean save(org.apache.cocoon.servlet.multipart.Part part)
          Save uploaded file
 boolean save(org.apache.cocoon.servlet.multipart.Part part, java.io.File file)
          Save uploaded file
 java.io.File save(org.apache.cocoon.environment.Request request, java.lang.String requestParameter)
          Saves the a file the request for a certain request parameter name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UploadHelper

public UploadHelper(java.io.File directory)
Ctor.

Parameters:
directory - The directory to save the files to.

UploadHelper

public UploadHelper(java.lang.String directoryPath)
Ctor.

Parameters:
directoryPath - The path of the directory to save the files to.
Method Detail

save

public boolean save(org.apache.cocoon.servlet.multipart.Part part)
Save uploaded file

Parameters:
part - The part of the multipart request.
Returns:
true if the upload succeeded, false otherwise.

save

public boolean save(org.apache.cocoon.servlet.multipart.Part part,
                    java.io.File file)
Save uploaded file

Parameters:
part - The part of the multipart request.
Returns:
true if the upload succeeded, false otherwise.

save

public java.io.File save(org.apache.cocoon.environment.Request request,
                         java.lang.String requestParameter)
                  throws java.lang.Exception
Saves the a file the request for a certain request parameter name.

Parameters:
request - The request.
requestParameter - The name of the <input type="file"/> request parameter value.
Returns:
The saved file or null if the upload was not successful.
Throws:
java.lang.Exception - when something went wrong.


Copyright © 1999-2005 Apache Software Foundation. All Rights Reserved.