Skip to content

Commit

Permalink
Related to [JENKINS-29034] - Modify filename to include date and time
Browse files Browse the repository at this point in the history
  • Loading branch information
recena committed Jun 23, 2015
1 parent bb6f466 commit 51551c8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/java/com/cloudbees/jenkins/support/SupportAction.java
Expand Up @@ -26,12 +26,14 @@

import com.cloudbees.jenkins.support.api.Component;
import com.cloudbees.jenkins.support.api.SupportProvider;

import hudson.Extension;
import hudson.model.RootAction;
import hudson.security.ACL;
import hudson.security.Permission;
import jenkins.model.Jenkins;
import net.sf.json.JSONObject;

import org.acegisecurity.context.SecurityContext;
import org.acegisecurity.context.SecurityContextHolder;
import org.jvnet.localizer.Localizable;
Expand All @@ -42,12 +44,16 @@
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.TimeZone;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand Down Expand Up @@ -146,8 +152,10 @@ public void doDownload(StaplerRequest req, StaplerResponse rsp) throws ServletEx
if (supportPlugin != null) {
SupportProvider supportProvider = supportPlugin.getSupportProvider();
if (supportProvider != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss");
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
// let the provider name it
filename = supportProvider.getName();
filename = supportProvider.getName() + "_" + dateFormat.format(new Date());
}
}
rsp.addHeader("Content-Disposition", "inline; filename=" + filename + ".zip;");
Expand Down

0 comments on commit 51551c8

Please sign in to comment.