Package org.silverpeas.core.io.upload
Class UploadedFile
- java.lang.Object
-
- org.silverpeas.core.io.upload.UploadedFile
-
public class UploadedFile extends Object
Representation of an uploaded file.
EachUploadedFile
is associated to a uniqueUploadSession
instance. So, it can not be possible to get severalUploadedFile
from anUploadSession
.- Author:
- Yohann Chastagnier
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.commons.fileupload.FileItem
asFileItem()
Converts the current instance into aFileItem
one.static UploadedFile
from(Map<String,String[]> parameters, String uploadSessionId, User uploader)
Creates a representation of an uploaded file from the specified file parameters, the upload session identifier and the user uploading the file.String
getDescription()
Gets the description filled by the user for the uploaded file.File
getFile()
Gets the uploaded file.String
getTitle()
Gets the title filled by the user for the uploaded file.UploadSession
getUploadSession()
Gets the upload files session.void
registerAttachment(ContributionIdentifier contributionId, String contributionLanguage, boolean indexIt)
Registers in Silverpeas a document attached to the given contribution and for which this file stores its content.
-
-
-
Method Detail
-
from
public static UploadedFile from(Map<String,String[]> parameters, String uploadSessionId, User uploader)
Creates a representation of an uploaded file from the specified file parameters, the upload session identifier and the user uploading the file. identifier.- Parameters:
parameters
- upload parameters in which are provided data about the file (title, description, ...)uploadSessionId
- the unique identifier of a files upload session.uploader
- the user that has uploaded a file.- Returns:
- an
UploadedFile
instance corresponding to a file that has been uploaded by a user.
-
getUploadSession
public UploadSession getUploadSession()
Gets the upload files session.- Returns:
- the session in which this file has been uploaded.
-
getFile
public File getFile()
Gets the uploaded file.- Returns:
- a
File
instance of the uploaded file.
-
getTitle
public String getTitle()
Gets the title filled by the user for the uploaded file.- Returns:
- the title of the content of the file.
-
getDescription
public String getDescription()
Gets the description filled by the user for the uploaded file.- Returns:
- a short description about the content of the file.
-
asFileItem
public org.apache.commons.fileupload.FileItem asFileItem()
Converts the current instance into aFileItem
one.- Returns:
- a
FileItem
instance.
-
registerAttachment
public void registerAttachment(ContributionIdentifier contributionId, String contributionLanguage, boolean indexIt)
Registers in Silverpeas a document attached to the given contribution and for which this file stores its content. Please notice that the uploaded content is deleted from its original location. For now, as this method is exclusively used for contribution creations, the treatment doesn't search for existing attachments. In the future and if updates will be handled, the treatment must evolve to search for existing attachment related to the contribution.- Parameters:
contributionId
- the identifier of a contribution in Silverpeas.contributionLanguage
- the language in which the contribution is authored.indexIt
- should the content of the file be indexed?
-
-