createLocalFileFromInputStream(is, baseLocalFile);
}
protected void createLocalFileFromInputStream(InputStream is, File baseLocalFile) throws IOException {
FileOutputStream tos = null;
FileWorkArea workArea = null;
try {
if (!baseLocalFile.getParentFile().exists()) {
boolean directoriesCreated = false;
if (!baseLocalFile.getParentFile().exists()) {
directoriesCreated = baseLocalFile.getParentFile().mkdirs();
if (!directoriesCreated) {
// There is a chance that another VM created the directories. If not, we may not have
// proper permissions and this is an error we need to report.
if (!baseLocalFile.getParentFile().exists()) {
throw new RuntimeException("Unable to create middle directories for file: " +
baseLocalFile.getAbsolutePath());
}
}
}
}
workArea = broadleafFileService.initializeWorkArea();
File tmpFile = new File(FilenameUtils.concat(workArea.getFilePathLocation(), baseLocalFile.getName()));
tos = new FileOutputStream(tmpFile);
IOUtils.copy(is, tos);