Skip to content

Commit

Permalink
Merge pull request #38 from recena/master
Browse files Browse the repository at this point in the history
[JENKINS-29034] - Modify filename to include date and time
  • Loading branch information
christ66 committed Jun 25, 2015
2 parents bb6f466 + 0cfb539 commit fc49e8e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 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 @@ -150,7 +156,10 @@ public void doDownload(StaplerRequest req, StaplerResponse rsp) throws ServletEx
filename = supportProvider.getName();
}
}
rsp.addHeader("Content-Disposition", "inline; filename=" + filename + ".zip;");

SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss");
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
rsp.addHeader("Content-Disposition", "inline; filename=" + filename + "_" + dateFormat.format(new Date()) + ".zip;");
final ServletOutputStream servletOutputStream = rsp.getOutputStream();
try {
SupportPlugin.setRequesterAuthentication(Jenkins.getAuthentication());
Expand Down

0 comments on commit fc49e8e

Please sign in to comment.