Class UploadedFile
- java.lang.Object
-
- net.sf.basedb.clients.web.fileupload.UploadedFile
-
public class UploadedFile extends Object
Objects of this class can be used to get information about an uploaded file and save the file to a directory in the filesystem. If the file is not saved, it will be deleted once the object is garbage collected.- Version:
- 2.0
- Author:
- Nicklas
-
-
Constructor Summary
Constructors Constructor Description UploadedFile(FileUpload fu, String formName, String filename, String mimeType)
Create a newUploadedFile
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getExtension()
Get the extension of the original filename.String
getFilename()
Get the original filename of the uploaded file.String
getFormName()
Get the name of the form field that this file was selected in.InputStream
getInputStream()
Get an input stream for uploading the file.String
getMimeType()
Get the MIME type of the uploaded file.void
writeTo(OutputStream out)
Upload the file and write the data to the specified output stream.
-
-
-
Field Detail
-
fu
private FileUpload fu
-
formName
private final String formName
-
filename
private final String filename
-
mimeType
private final String mimeType
-
-
Constructor Detail
-
UploadedFile
UploadedFile(FileUpload fu, String formName, String filename, String mimeType)
Create a newUploadedFile
object. Use theFileUpload.getFile(String)
orFileUpload.getFileValues(String)
method to get an object representing the uploaded file.- Parameters:
fu
- TheFileUpload
object responsible for the uploadformName
- The name of the form field with this filemimeType
- The MIME type of the file, or NULL if it is not knownfilename
- The original filename of the file, or NULL if it is not known
-
-
Method Detail
-
getFormName
public String getFormName()
Get the name of the form field that this file was selected in.- Since:
- 2.16
-
getFilename
public String getFilename()
Get the original filename of the uploaded file. This is the name the file had on the client computer.- Returns:
- The original name of the file, or NULL if it is not known
-
getExtension
public String getExtension()
Get the extension of the original filename. The extension is the part of the filename after the last dot. If the file doesn't have an extension NULL is returned.- Returns:
- The extension of the file, or NULL if none exists
-
getMimeType
public String getMimeType()
Get the MIME type of the uploaded file.- Returns:
- The MIME type of the file, or NULL if it is not known
-
writeTo
public void writeTo(OutputStream out) throws IOException, UploadAbortedException
Upload the file and write the data to the specified output stream.- Parameters:
out
- The stream to write to- Throws:
IOException
UploadAbortedException
-
getInputStream
public InputStream getInputStream() throws IOException, UploadAbortedException
Get an input stream for uploading the file.- Returns:
- An input stream to read from
- Throws:
IOException
- If reading the input stream fails.UploadAbortedException
- If the upload has been requested to be aborted.
-
-