@@ -602,7 +602,7 @@ protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws Se
602
602
}
603
603
604
604
InputStream resourceInputStream = null ;
605
-
605
+ File tempContentFile = null ;
606
606
try {
607
607
// Append data specified in ranges to existing content for this
608
608
// resource - create a temp. file on the local filesystem to
@@ -611,8 +611,8 @@ protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws Se
611
611
if (range == IGNORE ) {
612
612
resourceInputStream = req .getInputStream ();
613
613
} else {
614
- File contentFile = executePartialPut (req , range , path );
615
- resourceInputStream = new FileInputStream (contentFile );
614
+ tempContentFile = executePartialPut (req , range , path );
615
+ resourceInputStream = new FileInputStream (tempContentFile );
616
616
}
617
617
618
618
if (resources .write (path , resourceInputStream , true )) {
@@ -636,6 +636,9 @@ protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws Se
636
636
// Ignore
637
637
}
638
638
}
639
+ if (tempContentFile != null ) {
640
+ tempContentFile .delete ();
641
+ }
639
642
}
640
643
}
641
644
@@ -658,13 +661,7 @@ protected File executePartialPut(HttpServletRequest req, ContentRange range, Str
658
661
// resource - create a temp. file on the local filesystem to
659
662
// perform this operation
660
663
File tempDir = (File ) getServletContext ().getAttribute (ServletContext .TEMPDIR );
661
- // Convert all '/' characters to '.' in resourcePath
662
- String convertedResourcePath = path .replace ('/' , '.' );
663
- File contentFile = new File (tempDir , convertedResourcePath );
664
- if (contentFile .createNewFile ()) {
665
- // Clean up contentFile when Tomcat is terminated
666
- contentFile .deleteOnExit ();
667
- }
664
+ File contentFile = File .createTempFile ("put-part-" , null , tempDir );
668
665
669
666
try (RandomAccessFile randAccessContentFile = new RandomAccessFile (contentFile , "rw" )) {
670
667
0 commit comments