• Post Reply Bookmark Topic Watch Topic
  • New Topic

End-of-central-directory signature not found during zip download  RSS feed

Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone I have a problem during a zip file download.

I have a servlet which return the required file:

protected void doGet(final HttpServletRequest req, final HttpServletResponse resp)
throws ServletException, IOException{
// super.doGet(req, resp);
final String params = this.requestExtractor(req);
final File artifactDir = GeneralHelper.getArtifactsRepo();
final File artifactFile = new File(artifactDir, params);
final String[] splittedParams = params.split("/");

if (artifactFile.exists()) {
//resp.setContentType(new MimetypesFileTypeMap().getContentType(artifactFile));

resp.setHeader("Content-Disposition", "attachment; filename="
+ splittedParams[splittedParams.length - 1]);

final OutputStream out = resp.getOutputStream();
final FileInputStream in = new FileInputStream(artifactFile);

final String cacheControl = (String) ConfigHelper
resp.setHeader("Cache-Control", cacheControl); // HTTP 1.1
resp.setHeader("Pragma", cacheControl); // HTTP 1.0

final byte buffer[] = new byte[512 * 1024];
int nbLecture;

while ((nbLecture = in.read(buffer)) != -1) {
out.write(buffer, 0, nbLecture);

} finally {

} else {
resp.sendError(HttpServletResponse.SC_NOT_FOUND, "Resource not found ["
+ splittedParams[splittedParams.length - 1] + "]");


I download it with "wget" under Ubuntu for example: wget http://localhost:9090/webapp/rest/artifacts/components/component-1.zip

But when I try a "unzip component-1.zip" for this file, its doesn't work :'( and the following message is displayed in Console:

Archive: component-1.zip
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
unzip: cannot find zipfile directory in one of component-1.zip or
component-1.zip.zip, and cannot find component-1.zip.ZIP, period.

Do you have an idea to resolve this problem ?


Adrien Ruffie
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Problem resolved, it was due to a security constraint affected to this servlet, in the web.xml
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!