Class StreamingMultipartRequestResolver
java.lang.Object
org.dataone.mimemultipart.MultipartRequestResolver
edu.ucsb.nceas.metacat.restservice.multipart.StreamingMultipartRequestResolver
public class StreamingMultipartRequestResolver
extends org.dataone.mimemultipart.MultipartRequestResolver
This class will stream the file parts of the multipart request into a temporary file.
During the streaming, the checksum of the tmp file will be calculated and maintained.
The temple file with the checksum can be moved to the permanent location
rather than copying (read/write). So we only need to read/write once and the performance can be improved.
- Author:
- tao
-
Field Summary
-
Constructor Summary
ConstructorDescriptionStreamingMultipartRequestResolver
(String tmpUploadDir, int maxUploadSize) Constructor -
Method Summary
Modifier and TypeMethodDescriptionstatic void
deleteTempFile
(File temp) Delete a temp file either immediately or on program exists according to the configurationorg.dataone.service.types.v1.SystemMetadata
Get the system metadata object which was extracted from the sysmeta part.org.dataone.mimemultipart.MultipartRequest
resolveMultipart
(javax.servlet.http.HttpServletRequest request) static CheckedFile
writeStreamToCheckedFile
(File file, InputStream dataStream, String checksumAlgorithm, String pid) Write the input stream into the given fileName and directory while calculate the checksum.Methods inherited from class org.dataone.mimemultipart.MultipartRequestResolver
isMultipartContent
-
Field Details
-
SYSMETA
- See Also:
-
-
Constructor Details
-
StreamingMultipartRequestResolver
Constructor- Parameters:
tmpUploadDir
- the directory will temporarily host the stored files from the file parts in the http multiparts request.maxUploadSize
- the threshold size of files which can be allowed to upload
-
-
Method Details
-
resolveMultipart
public org.dataone.mimemultipart.MultipartRequest resolveMultipart(javax.servlet.http.HttpServletRequest request) throws IOException, org.apache.commons.fileupload.FileUploadException, InstantiationException, IllegalAccessException, org.dataone.exceptions.MarshallingException, NoSuchAlgorithmException - Overrides:
resolveMultipart
in classorg.dataone.mimemultipart.MultipartRequestResolver
- Throws:
IOException
org.apache.commons.fileupload.FileUploadException
InstantiationException
IllegalAccessException
org.dataone.exceptions.MarshallingException
NoSuchAlgorithmException
-
writeStreamToCheckedFile
public static CheckedFile writeStreamToCheckedFile(File file, InputStream dataStream, String checksumAlgorithm, String pid) throws NoSuchAlgorithmException, FileNotFoundException, IOException Write the input stream into the given fileName and directory while calculate the checksum.- Parameters:
file
- the file into which the stream will be written. It should exists already.dataStream
- the source streamchecksumAlgorithm
- the algorithm will be used for calculating the checksumpid
- the pid of the object (only used for debug information)- Returns:
- a CheckedFile object ( a File object with advertised checksum)
- Throws:
NoSuchAlgorithmException
FileNotFoundException
IOException
-
getSystemMetadataPart
public org.dataone.service.types.v1.SystemMetadata getSystemMetadataPart()Get the system metadata object which was extracted from the sysmeta part. The sysmeta wasn't stored in a file and was created an object directly. -
deleteTempFile
Delete a temp file either immediately or on program exists according to the configuration- Parameters:
temp
- the file will be deleted
-