8080import org .labkey .api .view .template .ClientDependency ;
8181import org .labkey .api .view .template .PageConfig ;
8282import org .labkey .api .writer .ContainerUser ;
83+ import org .labkey .vfs .FileLike ;
8384import org .springframework .beans .PropertyValue ;
8485import org .springframework .beans .PropertyValues ;
8586import org .springframework .web .util .WebUtils ;
@@ -986,29 +987,6 @@ private static void _prepareResponseForFile(HttpServletResponse response, Map<St
986987 response .setHeader (entry .getKey (), entry .getValue ());
987988 }
988989
989- /**
990- * Read the file and stream it to the browser through the response.
991- *
992- * @param detectContentType If set to true, then the content type is detected, else it is inferred from the extension
993- * of the file name.
994- */
995- public static void streamFile (HttpServletResponse response , File file , boolean asAttachment , boolean detectContentType ) throws IOException
996- {
997- if (detectContentType )
998- streamFile (response , Collections .emptyMap (), file , asAttachment );
999- else
1000- {
1001- try
1002- {
1003- streamFile (response , Collections .emptyMap (), file .getName (), new FileInputStream (file ), asAttachment );
1004- }
1005- catch (FileNotFoundException e )
1006- {
1007- throw new NotFoundException (file .getName ());
1008- }
1009- }
1010- }
1011-
1012990 public static void streamFile (HttpServletResponse response , Path file , boolean asAttachment , boolean detectContentType ) throws IOException
1013991 {
1014992 String filename = file .getFileName ().toString ();
@@ -1027,26 +1005,19 @@ public static void streamFile(HttpServletResponse response, Path file, boolean a
10271005 }
10281006 }
10291007
1030- @ Deprecated // Prefer the Path version
1031- public static void streamFile (HttpServletResponse response , File file , boolean asAttachment ) throws IOException
1008+ public static void streamFile (HttpServletResponse response , FileLike file , boolean asAttachment ) throws IOException
10321009 {
1033- streamFile (response , file .toPath (), asAttachment , false );
1010+ streamFile (response , file .toNioPathForRead (), asAttachment , false );
10341011 }
10351012
10361013 public static void streamFile (HttpServletResponse response , Path file , boolean asAttachment ) throws IOException
10371014 {
10381015 streamFile (response , file , asAttachment , false );
10391016 }
10401017
1041-
1042- /**
1043- * Read the file and stream it to the browser through the response. The content type of the file is detected
1044- * from the contents of the file.
1045- */
1046- @ Deprecated //Prefer the Path version
1047- public static void streamFile (@ NotNull HttpServletResponse response , @ NotNull Map <String , String > responseHeaders , File file , boolean asAttachment ) throws IOException
1018+ public static void streamFile (@ NotNull HttpServletResponse response , @ NotNull Map <String , String > responseHeaders , FileLike file , boolean asAttachment ) throws IOException
10481019 {
1049- streamFile (response ,responseHeaders , file .toPath (), asAttachment );
1020+ streamFile (response , responseHeaders , file .toNioPathForRead (), asAttachment );
10501021 }
10511022
10521023 public static void streamFile (@ NotNull HttpServletResponse response , @ NotNull Map <String , String > responseHeaders , Path file , boolean asAttachment ) throws IOException
0 commit comments