Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.autonomy.utilities
Class HTTPFileUpload

    java.lang.Object
      |
      +--com.autonomy.utilities.HTTPFileUpload

public class HTTPFileUpload
extends java.lang.Object

Class to process any form submitted from a HTML page using the:

`<form enctype="multipart/form-data">`

HTML tag. Example:

`HTTPFileUpload upload = new HTTPFileUpload( request.getInputStream(), "c:\\temp", 4096, 1024 );
String sFileName = upload.getParamter( sUploadFileFormName );
String sTextAreaContents = upload.getParameter( "myTextArea" );
String sFileContentType = upload.getContentType( sFileName );
`

The constructor takes an InputStream - for one, to allow easy debugging - eg
FileInputStream fis = new FileInputStream(new File("c:\\temp\\portlisten.txt"));
HTTPFileUpload upload = new HTTPFileUpload( fis, "c:\\temp", 4096, 1024 );
with the contents of a portlistened multipart form upload (just the body - no header) The interface has been designed to be similar to that of the HTTPServletRequest interface.

Field Summary
`int` | `m_nMaxLength`

Constructor Summary
`HTTPFileUpload(java.io.InputStream ISInput, java.lang.String sInputTempDir, int nInputMaxLength, int nInputBufferSize)` Constructor - parses the given input stream

Method Summary
`static boolean` | `byteArrayHasAtEnd(byte[] ba1, byte[] ba2)` See if the end of byte array 1 is identical to byte array 2
`static boolean` | `byteArrayHasAtEnd(byte[] ba1, byte[] ba2, int nEnd)` See if the subset of byte array 1 that ends at point nEnd, is identical to byte array 2
`java.lang.String` | `getContentType(java.lang.String sFileName)` Gets content type for a given filename.
`java.util.Enumeration` | `getFileNames()` Enumerates through the uploaded filenames
`java.lang.String` | `getOriginalFilename(java.lang.String sFileName)` Gets the original filename on a client machine of a given filename.
`java.lang.String` | `getParameter(java.lang.String sName)` Gets the first entry for a given name.
`java.util.Enumeration` | `getParameterNames()` Enumerates through the parameter names
`java.util.Vector` | `getParameterValues(java.lang.String sName)` Gets a parameter list

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### m_nMaxLength

    public int m_nMaxLength

Constructor Detail

### HTTPFileUpload

    public HTTPFileUpload(java.io.InputStream ISInput,
                          java.lang.String sInputTempDir,
                          int nInputMaxLength,
                          int nInputBufferSize)
                   throws java.lang.Exception

  Constructor - parses the given input stream

Parameters:
  `ISInput` - containing the data
  `sInputTempDir` - Temporary directory to store files
  `nInputMaxLength` - Max length of upload in bytes
  `nInputBufferSize` - buffer size for reading from input stream

Method Detail

### byteArrayHasAtEnd

    public static boolean byteArrayHasAtEnd(byte[] ba1,
                                            byte[] ba2)

  See if the end of byte array 1 is identical to byte array 2

### byteArrayHasAtEnd

    public static boolean byteArrayHasAtEnd(byte[] ba1,
                                            byte[] ba2,
                                            int nEnd)

  See if the subset of byte array 1 that ends at point nEnd, is identical to byte array 2

### getParameter

    public java.lang.String getParameter(java.lang.String sName)

  Gets the first entry for a given name. If this is the name of an uploaded file, it returns the full path to the file on the server it was saved as.

  Parameters:
    `sName` - name of element
  Returns:
    String value of that element or null if it was not found

### getParameterNames

    public java.util.Enumeration getParameterNames()

  Enumerates through the parameter names

### getFileNames

    public java.util.Enumeration getFileNames()

  Enumerates through the uploaded filenames

### getParameterValues

    public java.util.Vector getParameterValues(java.lang.String sName)

  Gets a parameter list

  Parameters:
    `sName` - name of parameter to get
  Returns:
    value list as a vector or null if it cannot be found

### getContentType

    public java.lang.String getContentType(java.lang.String sFileName)

  Gets content type for a given filename. If this is the name of an uploaded file, it returns the content type uploaded with it.

  Parameters:
    `sFileName` - name of element. You can get this by doing getParameter(sName) where sName is the name of the HTML element associated with the file
  Returns:
    content type: ie "text/html"

### getOriginalFilename

    public java.lang.String getOriginalFilename(java.lang.String sFileName)

  Gets the original filename on a client machine of a given filename.

  Parameters:
    `sFileName` - name of element. You can get this by doing getParameter(sName) where sName is the name of the HTML element associated with the file
  Returns:
    content type: ie "text/html"

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD