Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||||
IUploadFile |
|
| 1.0;1 |
1 | // Copyright 2004, 2005 The Apache Software Foundation |
|
2 | // |
|
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
|
4 | // you may not use this file except in compliance with the License. |
|
5 | // You may obtain a copy of the License at |
|
6 | // |
|
7 | // http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | // |
|
9 | // Unless required by applicable law or agreed to in writing, software |
|
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
|
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
12 | // See the License for the specific language governing permissions and |
|
13 | // limitations under the License. |
|
14 | ||
15 | package org.apache.tapestry.request; |
|
16 | ||
17 | import java.io.File; |
|
18 | import java.io.InputStream; |
|
19 | ||
20 | /** |
|
21 | * Represents a file uploaded from a client side form. |
|
22 | * |
|
23 | * @author Howard Lewis Ship |
|
24 | * @since 1.0.8 |
|
25 | */ |
|
26 | ||
27 | public interface IUploadFile |
|
28 | { |
|
29 | ||
30 | /** |
|
31 | * Returns the name of the file that was uploaded. This is just the filename |
|
32 | * portion of the complete path. |
|
33 | */ |
|
34 | ||
35 | String getFileName(); |
|
36 | ||
37 | /** |
|
38 | * Returns the complete path, as reported by the client browser. Different |
|
39 | * browsers report different things here. |
|
40 | * |
|
41 | * @since 2.0.4 |
|
42 | */ |
|
43 | ||
44 | String getFilePath(); |
|
45 | ||
46 | /** |
|
47 | * Returns an input stream of the content of the file. There is no guarantee |
|
48 | * that this stream will be valid after the end of the current request |
|
49 | * cycle, so it should be processed immediately. |
|
50 | * <p> |
|
51 | * As of release 1.0.8, this will be a a |
|
52 | * {@link java.io.ByteArrayInputStream}, but that, too, may change (a |
|
53 | * future implementation may upload the stream to a temporary file and |
|
54 | * return an input stream from that). |
|
55 | */ |
|
56 | ||
57 | InputStream getStream(); |
|
58 | ||
59 | /** |
|
60 | * Returns the MIME type specified when the file was uploaded. May return |
|
61 | * null if the content type is not known. |
|
62 | * |
|
63 | * @since 2.2 |
|
64 | */ |
|
65 | ||
66 | String getContentType(); |
|
67 | ||
68 | /** |
|
69 | * Writes the content of the file to a known location. This should be |
|
70 | * invoked at most once. In a standard implementation based on Jakarta |
|
71 | * FileUpload, this will often be implemented efficiently as a file rename. |
|
72 | * |
|
73 | * @since 3.0 |
|
74 | */ |
|
75 | ||
76 | void write(File file); |
|
77 | ||
78 | /** |
|
79 | * Returns true if the uploaded content is in memory. False generally means |
|
80 | * the content is stored in a temporary file. |
|
81 | */ |
|
82 | ||
83 | boolean isInMemory(); |
|
84 | ||
85 | /** |
|
86 | * Returns the size, in bytes, of the uploaded content. |
|
87 | * |
|
88 | * @since 3.0 |
|
89 | */ |
|
90 | ||
91 | long getSize(); |
|
92 | } |