com.ibm.commerce.server

Class UploadedFile

  • java.lang.Object
    • com.ibm.commerce.server.UploadedFile


  • public class UploadedFile
    extends java.lang.Object
    This class defines an object that represents an uploaded file.
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String COPYRIGHT
      IBM copyright notice field
    • Constructor Summary

      Constructors 
      Constructor and Description
      UploadedFile(org.apache.struts.upload.FormFile aFormFile)
      This is a constructor for this class.
      UploadedFile(java.lang.String filename, java.lang.String type, com.ibm.commerce.server.MultipartInputStreamHandler in, java.lang.String boundary)
      This is a constructor for this class.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      java.lang.String getContentType()
      This method gets the content type of the uploaded file.
      java.lang.String getFileName()
      This method gets the uploaded file name.
      java.io.InputStream getInputStream()
      This method returns the uploaded file as an input stream.
      int getLength()
      This method gets the length of the file.
      void readAndSaveFile(java.io.File f)
      This method reads in the uploaded file and saves it in the given File object.
      void readAndSaveFile(java.io.File f, boolean saveData)
      This method reads in the uploaded file and saves it in the given File object.
      void setContentType(java.lang.String contentType)
      This method sets the contentType of the uploaded file.
      void setFileName(java.lang.String fileName)
      This method sets the file name.
      void setLength(int length)
      This method sets the length if the file.
      java.lang.String toString()
      This method returns a String representation of a file.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • COPYRIGHT

        public static final java.lang.String COPYRIGHT
        IBM copyright notice field
        See Also:
        Constant Field Values
    • Constructor Detail

      • UploadedFile

        public UploadedFile(java.lang.String filename,
                            java.lang.String type,
                            com.ibm.commerce.server.MultipartInputStreamHandler in,
                            java.lang.String boundary)
        This is a constructor for this class.
        Parameters:
        filename - The file name of the uploaded file.
        type - The file type of uploaded file.
        in - a MultipartInputSreamHandler object.
        boundary - The boundary of the uploaded file.
      • UploadedFile

        public UploadedFile(org.apache.struts.upload.FormFile aFormFile)
        This is a constructor for this class. It creates a new UploadedFile instance based on a FormFile object.
        Parameters:
        aFormFile - The FormFile object used to create the UploadedFile instance.
    • Method Detail

      • getInputStream

        public java.io.InputStream getInputStream()
                                           throws java.io.IOException
        This method returns the uploaded file as an input stream.
        Returns:
        An InputStream object.
        Throws:
        java.io.IOException
      • readAndSaveFile

        public void readAndSaveFile(java.io.File f,
                                    boolean saveData)
                             throws java.io.IOException
        This method reads in the uploaded file and saves it in the given File object. If the content data is saved before, the saved data is written out instead.
        Parameters:
        f - A File object.
        saveData - Also save the content of the uploaded file in a byte array object if the value is true.
        Throws:
        java.io.IOException
      • readAndSaveFile

        public void readAndSaveFile(java.io.File f)
                             throws java.io.IOException
        This method reads in the uploaded file and saves it in the given File object.
        Parameters:
        f - A File object.
        Throws:
        java.io.IOException
      • getContentType

        public java.lang.String getContentType()
        This method gets the content type of the uploaded file.
        Returns:
        The content type of the uploaded file.
      • getFileName

        public java.lang.String getFileName()
        This method gets the uploaded file name.
        Returns:
        The name of uploaded file
      • getLength

        public int getLength()
        This method gets the length of the file.
        Returns:
        The length of the file.
      • setLength

        public void setLength(int length)
        This method sets the length if the file.
        Parameters:
        length - The value of the length to set.
      • setContentType

        public void setContentType(java.lang.String contentType)
        This method sets the contentType of the uploaded file.
        Parameters:
        contentType - The contentType to set.
      • toString

        public java.lang.String toString()
        This method returns a String representation of a file.
        Overrides:
        toString in class java.lang.Object
        Returns:
        This method returns a String representation of the uploaded file.
      • setFileName

        public void setFileName(java.lang.String fileName)
        This method sets the file name.
        Parameters:
        fileName - The file name to set.