|
@@ -44,8 +44,13 @@ public class ServletUtils {
|
|
|
*/
|
|
|
public static void writeAttachment(HttpServletResponse response, String filename, byte[] content) throws IOException {
|
|
|
// 设置 header 和 contentType
|
|
|
- response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8"));
|
|
|
- response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
|
|
+ if (filename.contains("mp4")) {
|
|
|
+ response.setHeader("Content-Disposition", "inline;");
|
|
|
+ response.setContentType("video/mp4");
|
|
|
+ } else {
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8"));
|
|
|
+ response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
|
|
+ }
|
|
|
// 输出附件
|
|
|
IoUtil.write(response.getOutputStream(), false, content);
|
|
|
}
|