/** * Calls SaveInputStreamTask to save an InputStream to disk. Method returns immediately. File is * saved in another thread. * * @param is InputStream to read data from * @param expectedLength Expected length of the stream. Size of the saved file will be checked * against this value. Verification skipped if expected length <= 0 * @param expectedMd5 Expected MD5 of the stream * @return Future that returns UploadedFileInfo when file is saved. * @throws IOException */ public Future<UploadedFileInfo> saveInputStream( InputStream is, long expectedLength, String expectedMd5) throws IOException { SaveInputStreamTask saveStreamTask = new SaveInputStreamTask(uploadDir, is, expectedLength, expectedMd5); Future<UploadedFileInfo> taskFuture = threadPoolSvc.submitCachedPool(saveStreamTask); return taskFuture; }
/** * Saves an inputstream that is a part of a file to disk. * * @param is InputStream that is a part of a file. * @param part Part number as a positive integer * @param isLastPart true if this part is the last one in sequence * @param fileId File ID to associate the file the part stream is part of * @param expectedLength Expected length of the stream. Size of the saved file will be checked * against this value. Verification skipped if expected length <= 0 * @param expectedMd5 Expected MD5 of the stream * @return Future that returns UploadedFileInfo when file is saved. * @throws IOException */ public Future<UploadedFileInfo> savePartStream( InputStream is, int part, boolean isLastPart, String fileId, long expectedLength, String expectedMd5) throws IOException { SavePartStreamTask partStreamTask = new SavePartStreamTask( uploadDir, fileId, is, part, isLastPart, expectedLength, expectedMd5); Future<UploadedFileInfo> taskFuture = threadPoolSvc.submitCachedPool(partStreamTask); return taskFuture; }