org.norther.tammi.spray.media
Interface FileUploadFilter

All Superinterfaces:
AccessController, Filter, KeyFilter, SecureFilter, SecureKeyFilter
All Known Implementing Classes:
DefaultFileUploadFilter

public interface FileUploadFilter
extends SecureKeyFilter

An interface to filters processing multipart/form-data requests that contain file(s) to be uploaded. The multipart/form-data Internet type is specified in RFC2388.

Additional information about Multipurpose Internet Mail Extensions (MIME) is provided in RFC's 2046-2049. Content-disposition headers are described in RFC2183.

Filter is secured, and the request needs to have write permission to each file name to be uploaded.

In order to upload files, a form with at least one input field of type 'file' is required. Set the form 'enctype' attribute to "multipart/form-data", and in the form action, set the upload key to correspond to the desired upload filter. The upload key value is either the field name of the form field containing the file name or an empty string if the filename in the content-disposition header is to be used as a basis for the filename.

About encoding.

  1. Although RFC2388 refers to RFC2047, which specifies a mechanism to pass non-ASCII data in the header information with 'encoded-words', it gives a restriction: "An 'encoded-word' MUST NOT be used in parameter of a MIME Content-Type or Content-Disposition field, or in any structured field body except within a 'comment' or 'phrase'". RFC2231, which extends RFC2047, is nevertheless referred to as a mechanism to pass file names in different charsets. Any of the mechanisms described in these RFC's doesn't seem to be applied by the user agents. Therefore, the value of filename in the content-disposition header should always be in ASCII.
  2. The encoding for a part should be passed in the charset parameter of the content type header as described in RFC2388. If such information isn't given, or otherwise cannot be concluded from the request, the configured encoding from HttpFilter is applied.

Author:
Marketta Priha

Method Summary
 File getUploadedFile(String file)
          Gets the full path of the uploaded file.
 int getUploadFileLimit()
          Gets the limit for the number of upload files.
 String getUploadFolderPath()
          Gets the folder path into which to upload the files.
 String getUploadKey()
          Gets the key of the folder into which to upload the files.
 int getUploadPathLimit()
          Gets the limit for the lenght of the upload path.
 int getUploadSizeLimit()
          Gets the limit for the size of the upload content.
 boolean isOverwriteEnabled()
          Gets the flag that indicates whether a file with the same name may overwrite an existing file in the upload folder.
 void setOverwriteEnabled(boolean flag)
          Sets the flag that indicates whether a file with the same name may overwrite an existing file in the upload folder.
 void setUploadFileLimit(int limit)
          Sets the limit for the number of upload files.
 void setUploadFolderPath(String folder)
          Sets the folder path into which to upload the files.
 void setUploadKey(String key)
          Sets the key of the folder into which to upload the files.
 void setUploadPathLimit(int limit)
          Sets a limit for the lenght of the upload path.
 void setUploadSizeLimit(int limit)
          Sets the limit for the size of the upload content.
 
Methods inherited from interface org.norther.tammi.spray.filter.SecureFilter
checkPermission, checkPermission, checkPermission
 
Methods inherited from interface org.norther.tammi.core.security.AccessController
addAllowedPermission, addDeniedPermission, allowedPermissions, allowedRoleSet, checkPermission, checkPermission, checkPermission, clearAllowedPermissions, clearDeniedPermissions, deniedPermissions, deniedRoleSet, getPermissibleRoles, getPermissibleRoles, getPermissibleRoles, isProtected, removeAllowedPermissions, removeDeniedPermissions, setAllowedPermissions, setDeniedPermissions
 
Methods inherited from interface javax.servlet.Filter
destroy, doFilter, init
 
Methods inherited from interface org.norther.tammi.spray.filter.KeyFilter
getKey, getKeyValue, getKeyValues, isLinkedKey, setKey, setLinkedKey
 
Methods inherited from interface javax.servlet.Filter
destroy, doFilter, init
 

Method Detail

getUploadKey

String getUploadKey()
Gets the key of the folder into which to upload the files.

Returns:
the upload key.

setUploadKey

void setUploadKey(String key)
Sets the key of the folder into which to upload the files.

Parameters:
key - the upload key.

getUploadFolderPath

String getUploadFolderPath()
Gets the folder path into which to upload the files. A relative folder will be combined with the upload key.

Returns:
the folder path.

setUploadFolderPath

void setUploadFolderPath(String folder)
Sets the folder path into which to upload the files. A relative folder will be combined with the upload key.

Parameters:
folder - the folder either as an absolute path or relative to the key folder.

isOverwriteEnabled

boolean isOverwriteEnabled()
Gets the flag that indicates whether a file with the same name may overwrite an existing file in the upload folder.

Returns:
true if files may be overwritten, otherwise false.

setOverwriteEnabled

void setOverwriteEnabled(boolean flag)
Sets the flag that indicates whether a file with the same name may overwrite an existing file in the upload folder.

Parameters:
flag - the flag, give true if files may be overwritten, otherwise false.

getUploadSizeLimit

int getUploadSizeLimit()
Gets the limit for the size of the upload content.

Returns:
the limit for the upload size in bytes, or -1 if unlimited.

setUploadSizeLimit

void setUploadSizeLimit(int limit)
Sets the limit for the size of the upload content. The limit is checked against the request size, so some extra may be needed.

Parameters:
limit - the limit for the upload size in bytes, or -1 if unlimited.

getUploadPathLimit

int getUploadPathLimit()
Gets the limit for the lenght of the upload path.

Returns:
the limit for the upload path in chars, or -1 if unlimited.

setUploadPathLimit

void setUploadPathLimit(int limit)
Sets a limit for the lenght of the upload path.

Parameters:
limit - the limit for the upload path in chars, or -1 if unlimited.

getUploadFileLimit

int getUploadFileLimit()
Gets the limit for the number of upload files.

Returns:
the limit for the upload files, or -1 if unlimited.

setUploadFileLimit

void setUploadFileLimit(int limit)
Sets the limit for the number of upload files. Files exceeding the limit will be deleted upon new uploads.

Parameters:
limit - the limit for the upload files, or -1 if unlimited.

getUploadedFile

File getUploadedFile(String file)
Gets the full path of the uploaded file.

Parameters:
file - the uploaded file.
Returns:
the uploaded file path.


Copyright © 2004 The Norther Organization. All rights reserved.