|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.wicket.markup.html.form.upload.FileUpload
public class FileUpload
Model for file uploads. Objects of this class should not be kept between requests, and should
therefore be marked as transient
if they become a property of an IModel.
Constructor Summary | |
---|---|
FileUpload(FileItem item)
Constructor |
Method Summary | |
---|---|
void |
closeStreams()
Close the streams which has been opened when getting the InputStream using getInputStream() . |
void |
delete()
Deletes temp file from disk |
byte[] |
getBytes()
|
String |
getClientFileName()
|
String |
getContentType()
|
InputStream |
getInputStream()
Get an input stream for the file uploaded. |
byte[] |
getMD5()
Get the MD5 checksum. |
long |
getSize()
|
void |
writeTo(File file)
Saves this file upload to a given file on the server side. |
void |
writeTo(File file,
int bufSize)
Saves this file upload to a given file on the server side. |
File |
writeToTempFile()
Convenience method that copies the input stream returned by getInputStream() into a
temporary file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FileUpload(FileItem item)
item
- The uploaded file itemMethod Detail |
---|
public final void closeStreams()
getInputStream()
. All the input streams are closed at the end of the request. This
is done when the FileUploadField, which is associated with this FileUpload is detached.
If an exception is thrown when closing the input streams, we ignore it, because the stream might have been closed already.
public void delete()
public byte[] getBytes()
public byte[] getMD5()
public String getClientFileName()
public String getContentType()
public InputStream getInputStream() throws IOException
writeTo(File)
for persisting the uploaded file. This can be if you need to react
upon the content of the file or need to persist it elsewhere, i.e. a database or external
filesystem.
PLEASE NOTE!
The InputStream return will be closed be Wicket at the end of the request. If you need it
across a request you need to hold on to this FileUpload instead.
IOException
public long getSize()
public void writeTo(File file) throws IOException
file
- The file
IOException
public void writeTo(File file, int bufSize) throws IOException
file
- The filebufSize
- The memory buffer size
IOException
public final File writeToTempFile() throws IOException
getInputStream()
into a
temporary file.
Only use this if you actually need a File
to work with, in all other cases use
getInputStream()
or getBytes()
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |