Class UploadedFile
java.lang.Object
net.sf.basedb.clients.web.fileupload.UploadedFile
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
-
Field Summary
-
Constructor Summary
ConstructorDescriptionUploadedFile
(FileUpload fu, String formName, String filename, String mimeType) Create a newUploadedFile
object. -
Method Summary
Modifier and TypeMethodDescriptionGet the extension of the original filename.Get the original filename of the uploaded file.Get the name of the form field that this file was selected in.Get an input stream for uploading the file.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 Details
-
fu
-
formName
-
filename
-
mimeType
-
-
Constructor Details
-
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 Details
-
getFormName
Get the name of the form field that this file was selected in.- Since:
- 2.16
-
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
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
Get the MIME type of the uploaded file.- Returns:
- The MIME type of the file, or NULL if it is not known
-
writeTo
Upload the file and write the data to the specified output stream.- Parameters:
out
- The stream to write to- Throws:
IOException
UploadAbortedException
-
getInputStream
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.
-