delete zip after download
This commit is contained in:
parent
a5cf24366e
commit
53aece5e85
@ -23,6 +23,8 @@ public class DownloadZip extends AuthenticatedServlet {
|
|||||||
protected void doAuthenticatedGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
protected void doAuthenticatedGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
String zipFilename = req.getParameter(PARAMETER_FILENAME);
|
String zipFilename = req.getParameter(PARAMETER_FILENAME);
|
||||||
File zipFile = new File(tempDir, zipFilename);
|
File zipFile = new File(tempDir, zipFilename);
|
||||||
|
|
||||||
|
if (zipFile.exists()) {
|
||||||
if (zipFile.getParentFile().getCanonicalPath().equals(tempDir.getCanonicalPath())) {
|
if (zipFile.getParentFile().getCanonicalPath().equals(tempDir.getCanonicalPath())) {
|
||||||
resp.addHeader("Content-Disposition", String.format("attachment; filename=\"%s\"", zipFilename));
|
resp.addHeader("Content-Disposition", String.format("attachment; filename=\"%s\"", zipFilename));
|
||||||
resp.setContentType("application/zip");
|
resp.setContentType("application/zip");
|
||||||
@ -30,8 +32,12 @@ public class DownloadZip extends AuthenticatedServlet {
|
|||||||
FileInputStream fileInputStream = new FileInputStream(zipFile);
|
FileInputStream fileInputStream = new FileInputStream(zipFile);
|
||||||
fileInputStream.transferTo(resp.getOutputStream());
|
fileInputStream.transferTo(resp.getOutputStream());
|
||||||
fileInputStream.close();
|
fileInputStream.close();
|
||||||
|
zipFile.delete();
|
||||||
} else {
|
} else {
|
||||||
throw new ServletException("-.-");
|
throw new ServletException("-.-");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
resp.sendRedirect("/mavor");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
<%@ page isELIgnored="false" %>
|
<%@ page isELIgnored="false" %>
|
||||||
<html>
|
<html>
|
||||||
<body style="background-color:black; color:white">
|
<body style="background-color:black; color:white">
|
||||||
Output:<br/>
|
Download dependencies (Link only works once!): <a href="/mavor/download/zip?file=${zipFilename}">${zipFilename}</a><br/>
|
||||||
<pre>${stdout}</pre><br/>
|
<a href="/mavor/logout">logout</a> | <a href="/mavor">back</a><br/>
|
||||||
File: <a href="/mavor/download/zip?file=${zipFilename}">${zipFilename}</a><br/>
|
Maven Output:<br/>
|
||||||
<a href="/mavor/logout">logout</a> | <a href="/mavor">back</a>
|
<pre>${stdout}</pre>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user