This is an automated email from the ASF dual-hosted git repository.

wuzhiguo pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 9847d23c51 AMBARI-25545: Downloaded zip-file name shows empty in the 
fileview (#3545)
9847d23c51 is described below

commit 9847d23c51f753789a49bf384dfcd716071a80c1
Author: Yu Hou <[email protected]>
AuthorDate: Sun Nov 20 01:49:16 2022 +0800

    AMBARI-25545: Downloaded zip-file name shows empty in the fileview (#3545)
---
 .../java/org/apache/ambari/view/filebrowser/DownloadService.java   | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git 
a/contrib/views/files/src/main/java/org/apache/ambari/view/filebrowser/DownloadService.java
 
b/contrib/views/files/src/main/java/org/apache/ambari/view/filebrowser/DownloadService.java
index 81ac40dd58..e7ea16bf14 100644
--- 
a/contrib/views/files/src/main/java/org/apache/ambari/view/filebrowser/DownloadService.java
+++ 
b/contrib/views/files/src/main/java/org/apache/ambari/view/filebrowser/DownloadService.java
@@ -62,6 +62,7 @@ import java.util.Queue;
 import java.util.UUID;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
+import java.net.URLEncoder;
 
 /**
  * Service for download and aggregate files
@@ -113,12 +114,12 @@ public class DownloadService extends HdfsService {
       ResponseBuilder result = Response.ok(fs);
       if (download) {
         result.header("Content-Disposition",
-          "attachment; filename=\"" + status.getPath().getName() + 
"\"").type(MediaType.APPLICATION_OCTET_STREAM);
+          "attachment; filename=\"" + 
URLEncoder.encode(status.getPath().getName(), "UTF-8") + 
"\"").type(MediaType.APPLICATION_OCTET_STREAM);
       } else {
         FileNameMap fileNameMap = URLConnection.getFileNameMap();
         String mimeType = 
fileNameMap.getContentTypeFor(status.getPath().getName());
         result.header("Content-Disposition",
-          "filename=\"" + status.getPath().getName() + "\"").type(mimeType);
+          "filename=\"" + URLEncoder.encode(status.getPath().getName(), 
"UTF-8") + "\"").type(mimeType);
       }
       return result.build();
     } catch (WebApplicationException ex) {
@@ -228,7 +229,7 @@ public class DownloadService extends HdfsService {
         }
       };
       return Response.ok(result)
-          .header("Content-Disposition", "inline; filename=\"" + name 
+"\"").build();
+          .header("Content-Disposition", "inline; filename=\"" + 
URLEncoder.encode(name, "UTF-8") +"\"").build();
     } catch (WebApplicationException ex) {
       LOG.error("Error occurred : ",ex);
       throw ex;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to