1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.portal.web.upload;
35
36 import fr.paris.lutece.util.filesystem.UploadUtil;
37
38 import org.apache.commons.fileupload.FileItem;
39 import org.apache.commons.fileupload.FileItemHeaders;
40 import org.apache.commons.io.FilenameUtils;
41
42 import java.io.File;
43 import java.io.IOException;
44 import java.io.InputStream;
45 import java.io.OutputStream;
46 import java.io.UnsupportedEncodingException;
47
48
49
50
51 public class NormalizeFileItem implements FileItem
52 {
53 private static final long serialVersionUID = 8696893066570050604L;
54 private FileItem _item;
55
56
57
58
59
60
61
62 public NormalizeFileItem( FileItem item )
63 {
64 _item = item;
65 }
66
67
68
69
70 @Override
71 public void delete( )
72 {
73 _item.delete( );
74 }
75
76
77
78
79 @Override
80 public byte [ ] get( )
81 {
82 return _item.get( );
83 }
84
85
86
87
88 @Override
89 public String getContentType( )
90 {
91 return _item.getContentType( );
92 }
93
94
95
96
97 @Override
98 public String getFieldName( )
99 {
100 return _item.getFieldName( );
101 }
102
103
104
105
106 @Override
107 public InputStream getInputStream( ) throws IOException
108 {
109 return _item.getInputStream( );
110 }
111
112
113
114
115 @Override
116 public String getName( )
117 {
118 return UploadUtil.cleanFileName( FilenameUtils.getName( _item.getName( ) ) );
119 }
120
121
122
123
124 @Override
125 public OutputStream getOutputStream( ) throws IOException
126 {
127 return _item.getOutputStream( );
128 }
129
130
131
132
133 @Override
134 public long getSize( )
135 {
136 return _item.getSize( );
137 }
138
139
140
141
142 @Override
143 public String getString( )
144 {
145 return _item.getString( );
146 }
147
148
149
150
151 @Override
152 public String getString( String encoding ) throws UnsupportedEncodingException
153 {
154 return _item.getString( encoding );
155 }
156
157
158
159
160 @Override
161 public boolean isFormField( )
162 {
163 return _item.isFormField( );
164 }
165
166
167
168
169 @Override
170 public boolean isInMemory( )
171 {
172 return _item.isInMemory( );
173 }
174
175
176
177
178 @Override
179 public void setFieldName( String name )
180 {
181 _item.setFieldName( name );
182 }
183
184
185
186
187 @Override
188 public void setFormField( boolean state )
189 {
190 _item.setFormField( state );
191 }
192
193
194
195
196 @Override
197 public void write( File file ) throws Exception
198 {
199 _item.write( file );
200 }
201
202
203
204
205 @Override
206 public FileItemHeaders getHeaders( )
207 {
208 return _item.getHeaders( );
209 }
210
211
212
213
214 @Override
215 public void setHeaders( FileItemHeaders headers )
216 {
217 _item.setHeaders( headers );
218 }
219 }