Tabnine Logo
DiskFileItem
Code IndexAdd Tabnine to your IDE (free)

How to use
DiskFileItem
in
org.apache.tomcat.util.http.fileupload.disk

Best Java code snippets using org.apache.tomcat.util.http.fileupload.disk.DiskFileItem (Showing top 20 results out of 315)

origin: codefollower/Tomcat-Research

@Override
public String getHeader(String name) {
  if (fileItem instanceof DiskFileItem) {
    return ((DiskFileItem) fileItem).getHeaders().getHeader(name);
  }
  return null;
}
origin: org.apache.geronimo.ext.tomcat/util

/**
 * Returns a string representation of this object.
 *
 * @return a string representation of this object.
 */
@Override
public String toString() {
  return String.format("name=%s, StoreLocation=%s, size=%s bytes, isFormField=%s, FieldName=%s",
         getName(), getStoreLocation(), Long.valueOf(getSize()),
         Boolean.valueOf(isFormField()), getFieldName());
}
origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

/**
 * Create a new {@link DiskFileItem}
 * instance from the supplied parameters and the local factory
 * configuration.
 *
 * @param fieldName   The name of the form field.
 * @param contentType The content type of the form field.
 * @param isFormField <code>true</code> if this is a plain form field;
 *                    <code>false</code> otherwise.
 * @param fileName    The name of the uploaded file, if any, as supplied
 *                    by the browser or other client.
 *
 * @return The newly created file item.
 */
@Override
public FileItem createItem(String fieldName, String contentType,
    boolean isFormField, String fileName) {
  DiskFileItem result = new DiskFileItem(fieldName, contentType,
      isFormField, fileName, sizeThreshold, repository);
  result.setDefaultCharset(defaultCharset);
  return result;
}
origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

/**
 * Deletes the underlying storage for a file item, including deleting any
 * associated temporary disk file. Although this storage will be deleted
 * automatically when the <code>FileItem</code> instance is garbage
 * collected, this method can be used to ensure that this is done at an
 * earlier time, thus preserving system resources.
 */
@Override
public void delete() {
  cachedContent = null;
  File outputFile = getStoreLocation();
  if (outputFile != null && !isInMemory() && outputFile.exists()) {
    outputFile.delete();
  }
}
origin: codefollower/Tomcat-Research

if (isInMemory()) {
  FileOutputStream fout = null;
  try {
    fout = new FileOutputStream(file);
    fout.write(get());
  } finally {
    if (fout != null) {
  File outputFile = getStoreLocation();
  if (outputFile != null) {
origin: org.apache.coyote/com.springsource.org.apache.coyote

/**
 * Returns the contents of the file as a String, using the default
 * character encoding.  This method uses {@link #get()} to retrieve the
 * contents of the file.
 *
 * @return The contents of the file, as a string.
 *
 * TODO Consider making this method throw UnsupportedEncodingException.
 */
@Override
public String getString() {
  byte[] rawdata = get();
  String charset = getCharSet();
  if (charset == null) {
    charset = DEFAULT_CHARSET;
  }
  try {
    return new String(rawdata, charset);
  } catch (UnsupportedEncodingException e) {
    return new String(rawdata);
  }
}
origin: org.jboss.web/jbossweb

if (isInMemory()) {
  if (cachedContent == null) {
    cachedContent = dfos.getData();
byte[] fileData = new byte[(int) getSize()];
FileInputStream fis = null;
origin: org.jboss.web/jbossweb

/**
 * Create a new {@link DiskFileItem}
 * instance from the supplied parameters and the local factory
 * configuration.
 *
 * @param fieldName   The name of the form field.
 * @param contentType The content type of the form field.
 * @param isFormField <code>true</code> if this is a plain form field;
 *                    <code>false</code> otherwise.
 * @param fileName    The name of the uploaded file, if any, as supplied
 *                    by the browser or other client.
 *
 * @return The newly created file item.
 */
public FileItem createItem(String fieldName, String contentType,
    boolean isFormField, String fileName) {
  DiskFileItem result = new DiskFileItem(fieldName, contentType,
      isFormField, fileName, sizeThreshold, repository);
  FileCleaningTracker tracker = getFileCleaningTracker();
  if (tracker != null) {
    tracker.track(result.getTempFile(), this);
  }
  return result;
}
origin: org.jboss.web/jbossweb

/**
 * Deletes the underlying storage for a file item, including deleting any
 * associated temporary disk file. Although this storage will be deleted
 * automatically when the <code>FileItem</code> instance is garbage
 * collected, this method can be used to ensure that this is done at an
 * earlier time, thus preserving system resources.
 */
public void delete() {
  cachedContent = null;
  File outputFile = getStoreLocation();
  if (outputFile != null && outputFile.exists()) {
    outputFile.delete();
  }
}
origin: org.apache.coyote/com.springsource.org.apache.coyote

/**
 * Returns the contents of the file as a String, using the specified
 * encoding.  This method uses {@link #get()} to retrieve the
 * contents of the file.
 *
 * @param charset The charset to use.
 *
 * @return The contents of the file, as a string.
 *
 * @throws UnsupportedEncodingException if the requested character
 *                                      encoding is not available.
 */
@Override
public String getString(final String charset)
  throws UnsupportedEncodingException {
  return new String(get(), charset);
}
origin: codefollower/Tomcat-Research

/**
 * Returns the content charset passed by the agent or <code>null</code> if
 * not defined.
 *
 * @return The content charset passed by the agent or <code>null</code> if
 *         not defined.
 */
public String getCharSet() {
  ParameterParser parser = new ParameterParser();
  parser.setLowerCaseNames(true);
  // Parameter parser can handle null input
  Map<String,String> params = parser.parse(getContentType(), ';');
  return params.get("charset");
}
origin: com.ovea.tajin.server/tajin-server-tomcat7

/**
 * 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.
 *
 * @throws IOException if an error occurs.
 */
public OutputStream getOutputStream()
  throws IOException {
  if (dfos == null) {
    File outputFile = getTempFile();
    dfos = new DeferredFileOutputStream(sizeThreshold, outputFile);
  }
  return dfos;
}
origin: codefollower/Tomcat-Research

  /**
   * Create a new {@link DiskFileItem}
   * instance from the supplied parameters and the local factory
   * configuration.
   *
   * @param fieldName   The name of the form field.
   * @param contentType The content type of the form field.
   * @param isFormField <code>true</code> if this is a plain form field;
   *                    <code>false</code> otherwise.
   * @param fileName    The name of the uploaded file, if any, as supplied
   *                    by the browser or other client.
   *
   * @return The newly created file item.
   */
  @Override
  public FileItem createItem(String fieldName, String contentType,
      boolean isFormField, String fileName) {
    return new DiskFileItem(fieldName, contentType,
        isFormField, fileName, sizeThreshold, repository);
  }
}
origin: com.ovea.tajin.server/tajin-server-tomcat7

if (isInMemory()) {
  FileOutputStream fout = null;
  try {
    fout = new FileOutputStream(file);
    fout.write(get());
  } finally {
    if (fout != null) {
  File outputFile = getStoreLocation();
  if (outputFile != null) {
origin: com.ovea.tajin.server/tajin-server-tomcat7

/**
 * Returns the contents of the file as a String, using the default
 * character encoding.  This method uses {@link #get()} to retrieve the
 * contents of the file.
 *
 * @return The contents of the file, as a string.
 *
 * TODO Consider making this method throw UnsupportedEncodingException.
 */
public String getString() {
  byte[] rawdata = get();
  String charset = getCharSet();
  if (charset == null) {
    charset = DEFAULT_CHARSET;
  }
  try {
    return new String(rawdata, charset);
  } catch (UnsupportedEncodingException e) {
    return new String(rawdata);
  }
}
origin: codefollower/Tomcat-Research

if (isInMemory()) {
  if (cachedContent == null) {
    cachedContent = dfos.getData();
byte[] fileData = new byte[(int) getSize()];
InputStream fis = null;
origin: com.ovea.tajin.server/tajin-server-tomcat7

/**
 * Create a new {@link DiskFileItem}
 * instance from the supplied parameters and the local factory
 * configuration.
 *
 * @param fieldName   The name of the form field.
 * @param contentType The content type of the form field.
 * @param isFormField <code>true</code> if this is a plain form field;
 *                    <code>false</code> otherwise.
 * @param fileName    The name of the uploaded file, if any, as supplied
 *                    by the browser or other client.
 *
 * @return The newly created file item.
 */
public FileItem createItem(String fieldName, String contentType,
    boolean isFormField, String fileName) {
  DiskFileItem result = new DiskFileItem(fieldName, contentType,
      isFormField, fileName, sizeThreshold, repository);
  FileCleaningTracker tracker = getFileCleaningTracker();
  if (tracker != null) {
    tracker.track(result.getTempFile(), this);
  }
  return result;
}
origin: com.ovea.tajin.server/tajin-server-tomcat7

/**
 * Deletes the underlying storage for a file item, including deleting any
 * associated temporary disk file. Although this storage will be deleted
 * automatically when the <code>FileItem</code> instance is garbage
 * collected, this method can be used to ensure that this is done at an
 * earlier time, thus preserving system resources.
 */
public void delete() {
  cachedContent = null;
  File outputFile = getStoreLocation();
  if (outputFile != null && outputFile.exists()) {
    outputFile.delete();
  }
}
origin: com.ovea.tajin.server/tajin-server-tomcat7

/**
 * Returns the contents of the file as a String, using the specified
 * encoding.  This method uses {@link #get()} to retrieve the
 * contents of the file.
 *
 * @param charset The charset to use.
 *
 * @return The contents of the file, as a string.
 *
 * @throws UnsupportedEncodingException if the requested character
 *                                      encoding is not available.
 */
public String getString(final String charset)
  throws UnsupportedEncodingException {
  return new String(get(), charset);
}
origin: org.jboss.web/jbossweb

/**
 * Returns the content charset passed by the agent or <code>null</code> if
 * not defined.
 *
 * @return The content charset passed by the agent or <code>null</code> if
 *         not defined.
 */
public String getCharSet() {
  ParameterParser parser = new ParameterParser();
  parser.setLowerCaseNames(true);
  // Parameter parser can handle null input
  Map<String,String> params = parser.parse(getContentType(), ';');
  return params.get("charset");
}
org.apache.tomcat.util.http.fileupload.diskDiskFileItem

Javadoc

The default implementation of the org.apache.tomcat.util.http.fileupload.FileItem interface.

After retrieving an instance of this class from a org.apache.tomcat.util.http.fileupload.FileUpload instance (see org.apache.tomcat.util.http.fileupload.FileUpload#parseRequest(org.apache.tomcat.util.http.fileupload.RequestContext)), you may either request all contents of file at once using #get() or request an java.io.InputStream with #getInputStream() and process the file without attempting to load it into memory, which may come handy with large files.

Temporary files, which are created for file items, should be deleted later on.

Most used methods

  • getHeaders
    Returns the file item headers.
  • getStoreLocation
    Returns the java.io.File object for the FileItem's data's temporary location on the disk. Note that
  • <init>
    Constructs a new DiskFileItem instance.
  • get
    Returns the contents of the file as an array of bytes. If the contents of the file were not yet cach
  • getCharSet
    Returns the content charset passed by the agent or null if not defined.
  • getContentType
    Returns the content type passed by the agent or null if not defined.
  • getFieldName
    Returns the name of the field in the multipart form corresponding to this file item.
  • getName
    Returns the original filename in the client's filesystem.
  • getSize
    Returns the size of the file.
  • getTempFile
    Creates and returns a java.io.File representing a uniquely named temporary file in the configured re
  • getUniqueId
    Returns an identifier that is unique within the class loader used to load this class, but does not h
  • isFormField
    Determines whether or not a FileItem instance represents a simple form field.
  • getUniqueId,
  • isFormField,
  • isInMemory,
  • getOutputStream,
  • getString,
  • setDefaultCharset

Popular in Java

  • Reading from database using SQL prepared statement
  • requestLocationUpdates (LocationManager)
  • addToBackStack (FragmentTransaction)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now