File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
src/main/java/com/conveyal/analysis/util Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change 44import com .conveyal .file .FileUtils ;
55import com .conveyal .r5 .util .ExceptionUtils ;
66import org .apache .commons .fileupload .FileItem ;
7- import org .apache .commons .fileupload .disk .DiskFileItem ;
87import org .apache .commons .fileupload .disk .DiskFileItemFactory ;
98import org .apache .commons .fileupload .servlet .ServletFileUpload ;
109
@@ -109,13 +108,15 @@ public static File saveFileItemLocally(FileItem fileItem) {
109108 }
110109
111110 /**
112- * Move the contents of a `FileItem` to the given directory by calling `renameTo`.
111+ * Move the contents of a `FileItem` to the given directory by calling `write`. `DiskFileItem`s will call `renameTo`
112+ * if the `FileItem's contents are already on the disk.
113113 */
114114 public static File moveFileItemIntoDirectory (FileItem fileItem , File directory ) {
115115 File file = new File (directory , fileItem .getName ());
116- boolean renameSuccessful = ((DiskFileItem ) fileItem ).getStoreLocation ().renameTo (file );
117- if (!renameSuccessful ) {
118- throw AnalysisServerException .fileUpload ("Error storing file in directory on disk. File.renameTo() failed." );
116+ try {
117+ fileItem .write (file );
118+ } catch (Exception e ) {
119+ throw new AnalysisServerException (e , "Error storing file in directory on disk. FileItem.write() failed." );
119120 }
120121 return file ;
121122 }
You can’t perform that action at this time.
0 commit comments