1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.struts.upload;
19
20 import java.io.FileNotFoundException;
21 import java.io.IOException;
22 import java.io.InputStream;
23
24 /***
25 * <p> This interface represents a file that has been uploaded by a client. It
26 * is the only interface or class in upload package which is typically
27 * referenced directly by a Struts application. </p>
28 */
29 public interface FormFile {
30 /***
31 * <p> Returns the content type for this file. </p>
32 *
33 * @return A String representing content type.
34 */
35 public String getContentType();
36
37 /***
38 * <p> Sets the content type for this file. </p>
39 *
40 * @param contentType The content type for the file.
41 */
42 public void setContentType(String contentType);
43
44 /***
45 * <p> Returns the size of this file. </p>
46 *
47 * @return The size of the file, in bytes.
48 */
49 public int getFileSize();
50
51 /***
52 * <p> Sets the file size. </p>
53 *
54 * @param fileSize The size of the file, in bytes,
55 */
56 public void setFileSize(int fileSize);
57
58 /***
59 * <p> Returns the file name of this file. This is the base name of the
60 * file, as supplied by the user when the file was uploaded. </p>
61 *
62 * @return The base file name.
63 */
64 public String getFileName();
65
66 /***
67 * <p> Sets the file name of this file. </p>
68 *
69 * @param fileName The base file name.
70 */
71 public void setFileName(String fileName);
72
73 /***
74 * <p> Returns the data for the entire file as byte array. Care is needed
75 * when using this method, since a large upload could easily exhaust
76 * available memory. The preferred method for accessing the file data is
77 * {@link #getInputStream() getInputStream}. </p>
78 *
79 * @return The file data as a byte array.
80 * @throws FileNotFoundException if the uploaded file is not found.
81 * @throws IOException if an error occurred while reading the
82 * file.
83 */
84 public byte[] getFileData()
85 throws FileNotFoundException, IOException;
86
87 /***
88 * <p> Returns an input stream for this file. The caller must close the
89 * stream when it is no longer needed. </p>
90 *
91 * @throws FileNotFoundException if the uploaded file is not found.
92 * @throws IOException if an error occurred while reading the
93 * file.
94 */
95 public InputStream getInputStream()
96 throws FileNotFoundException, IOException;
97
98 /***
99 * <p> Destroys all content for the uploaded file, including any
100 * underlying data files. </p>
101 */
102 public void destroy();
103 }