From 7656b64af7f52b98747bb4da7e3d252c8ec4883a Mon Sep 17 00:00:00 2001 From: Liu Rui Date: Tue, 29 Oct 2024 13:44:52 +0800 Subject: [PATCH] =?UTF-8?q?fix-FileServer-=E4=B8=AD=E6=96=87=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=90=8D=E4=B8=8B=E8=BD=BD=E4=B9=B1=E7=A0=81=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/net/ximatai/muyun/fileserver/FileServer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/muyun-fileserver/src/main/java/net/ximatai/muyun/fileserver/FileServer.java b/muyun-fileserver/src/main/java/net/ximatai/muyun/fileserver/FileServer.java index d6369341..0afc87c9 100644 --- a/muyun-fileserver/src/main/java/net/ximatai/muyun/fileserver/FileServer.java +++ b/muyun-fileserver/src/main/java/net/ximatai/muyun/fileserver/FileServer.java @@ -13,6 +13,7 @@ import org.slf4j.LoggerFactory; import java.io.File; +import java.net.URLEncoder; import java.nio.charset.StandardCharsets; @ApplicationScoped @@ -109,10 +110,9 @@ private void download(RoutingContext ctx) { vertx.fileSystem().readFile(nameFilePath, result -> { if (result.succeeded()) { Buffer buffer = result.result(); - String fileName = new String(buffer.getBytes(), StandardCharsets.ISO_8859_1); if (fileObtained.exists()) { ctx.response() - .putHeader("Content-Disposition", "attachment; filename=" + fileName) + .putHeader("Content-Disposition", "attachment; filename*=UTF-8''" + URLEncoder.encode(buffer.toString(), StandardCharsets.UTF_8)) .putHeader("Content-type", "application/octet-stream") .sendFile(fileObtained.getPath()); // vertx.fileSystem().delete(fileObtained.getPath());