You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ma...@apache.org on 2002/12/25 05:05:07 UTC

cvs commit: jakarta-commons/fileupload/src/java/org/apache/commons/fileupload DefaultFileItem.java FileItem.java FileUpload.java

martinc     2002/12/24 20:05:07

  Modified:    fileupload/src/java/org/apache/commons/fileupload
                        DefaultFileItem.java FileItem.java FileUpload.java
  Log:
  Make getOutputStream() part of the FileItem interface, to allow
  implementations other than DefaultFileItem to be used.
  
  Reported by Susana Pereira.
  
  Revision  Changes    Path
  1.14      +19 -19    jakarta-commons/fileupload/src/java/org/apache/commons/fileupload/DefaultFileItem.java
  
  Index: DefaultFileItem.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/fileupload/src/java/org/apache/commons/fileupload/DefaultFileItem.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- DefaultFileItem.java	22 Aug 2002 04:41:29 -0000	1.13
  +++ DefaultFileItem.java	25 Dec 2002 04:05:07 -0000	1.14
  @@ -512,21 +512,6 @@
       }
   
   
  -    // --------------------------------------------------------- Public methods
  -
  -
  -    /**
  -     * Removes the file contents from the temporary storage.
  -     */
  -    protected void finalize()
  -    {
  -        if (storeLocation != null && storeLocation.exists())
  -        {
  -            storeLocation.delete();
  -        }
  -    }
  -
  -
       /**
        * Returns an {@link java.io.OutputStream OutputStream} that can
        * be used for storing the contents of the file.
  @@ -546,6 +531,21 @@
           else
           {
               return new FileOutputStream(storeLocation);
  +        }
  +    }
  +
  +
  +    // --------------------------------------------------------- Public methods
  +
  +
  +    /**
  +     * Removes the file contents from the temporary storage.
  +     */
  +    protected void finalize()
  +    {
  +        if (storeLocation != null && storeLocation.exists())
  +        {
  +            storeLocation.delete();
           }
       }
   
  
  
  
  1.11      +17 -4     jakarta-commons/fileupload/src/java/org/apache/commons/fileupload/FileItem.java
  
  Index: FileItem.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/fileupload/src/java/org/apache/commons/fileupload/FileItem.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- FileItem.java	20 Dec 2002 04:09:07 -0000	1.10
  +++ FileItem.java	25 Dec 2002 04:05:07 -0000	1.11
  @@ -66,6 +66,7 @@
   import java.io.File;
   import java.io.IOException;
   import java.io.InputStream;
  +import java.io.OutputStream;
   import java.io.Serializable;
   import java.io.UnsupportedEncodingException;
   
  @@ -277,5 +278,17 @@
        *              field; <code>false</code> if it represents an uploaded file.
        */
       void setIsFormField(boolean state);
  +
  +
  +    /**
  +     * Returns an {@link java.io.OutputStream OutputStream} that can
  +     * be used for storing the contents of the file.
  +     *
  +     * @return An {@link java.io.OutputStream OutputStream} that can be used
  +     *         for storing the contensts of the file.
  +     *
  +     * @exception IOException if an error occurs.
  +     */
  +    public OutputStream getOutputStream() throws IOException;
   
   }
  
  
  
  1.15      +7 -10     jakarta-commons/fileupload/src/java/org/apache/commons/fileupload/FileUpload.java
  
  Index: FileUpload.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/fileupload/src/java/org/apache/commons/fileupload/FileUpload.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- FileUpload.java	10 Nov 2002 06:31:10 -0000	1.14
  +++ FileUpload.java	25 Dec 2002 04:05:07 -0000	1.15
  @@ -443,8 +443,7 @@
                                   FileItem item = 
                                       createItem(sizeThreshold, path,
                                                  headers, requestSize);
  -                                OutputStream os = 
  -                                    ((DefaultFileItem) item).getOutputStream();
  +                                OutputStream os = item.getOutputStream();
                                   try
                                   {
                                       multi.readBodyData(os);
  @@ -474,8 +473,7 @@
                               FileItem item = createItem(sizeThreshold, 
                                                          path, headers,
                                                          requestSize);
  -                            OutputStream os = 
  -                                ((DefaultFileItem) item).getOutputStream();
  +                            OutputStream os = item.getOutputStream();
                               try
                               {
                                   multi.readBodyData(os);
  @@ -493,8 +491,7 @@
                               FileItem item = createItem(sizeThreshold,
                                                          path, headers,
                                                          requestSize);
  -                            OutputStream os = 
  -                                ((DefaultFileItem) item).getOutputStream();
  +                            OutputStream os = item.getOutputStream();
                               try
                               {
                                   multi.readBodyData(os);
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>