public class FileUpload extends Object implements IClusterable
transient
if they become a property of an IModel.Constructor and Description |
---|
FileUpload(org.apache.commons.fileupload.FileItem item)
Constructor
|
Modifier and Type | Method and Description |
---|---|
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() |
byte[] |
getDigest(String algorithm)
Get the MD5 checksum.
|
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.
|
File |
writeToTempFile()
Convenience method that copies the input stream returned by
getInputStream() into a
temporary file. |
public FileUpload(org.apache.commons.fileupload.FileItem item)
item
- The uploaded file itempublic 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[] getDigest(String algorithm)
algorithm
- the digest algorithm, e.g. MD5, SHA-1, SHA-256, SHA-512public 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 Exception
file
- The fileException
public final File writeToTempFile() throws Exception
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()
Exception
Copyright © 2006–2019 Apache Software Foundation. All rights reserved.