    001// Copyright 2007 The Apache Software Foundation
    002//
    003// Licensed under the Apache License, Version 2.0 (the "License");
    004// you may not use this file except in compliance with the License.
    005// You may obtain a copy of the License at
    006//
    007//     http://www.apache.org/licenses/LICENSE-2.0
    008//
    009// Unless required by applicable law or agreed to in writing, software
    010// distributed under the License is distributed on an "AS IS" BASIS,
    011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    012// See the License for the specific language governing permissions and
    013// limitations under the License.
    014
    015package org.apache.tapestry5.upload.services;
    016
    017import org.apache.tapestry5.upload.components.Upload;
    018
    019import java.io.File;
    020import java.io.InputStream;
    021
    022/**
    023 * Represents an uploaded file.
    024 *
    025 * @see Upload
    026 */
    027public interface UploadedFile
    028{
    029    /**
    030     * @return the MIME type specified when the file was uploaded.
    031     */
    032    String getContentType();
    033
    034    /**
    035     * @return the name of the file that was uploaded.
    036     */
    037    String getFileName();
    038
    039    /**
    040     * @return the complete path, as reported by the client browser.
    041     */
    042    String getFilePath();
    043
    044    /**
    045     * @return the size, in bytes, of the uploaded content.
    046     */
    047    long getSize();
    048
    049    /**
    050     * @return an input stream of the content of the file.
    051     */
    052    InputStream getStream();
    053
    054    /**
    055     * @return true if the uploaded content is in memory.
    056     */
    057    boolean isInMemory();
    058
    059    /**
    060     * Writes the content of the file to a known location.
    061     *
    062     * @param file Location to write file to
    063     */
    064    void write(File file);
    065}