use of jetbrains.buildServer.controllers.HttpDownloadProcessor in project teamcity-rest by JetBrains.
the class FilesSubResource method processCoreDownload.
private void processCoreDownload(@NotNull final Element element, @NotNull final HttpServletRequest request, @NotNull final HttpServletResponse response) {
setCacheControl(request, response);
boolean setContentDisposition = getSetContentDisposition(element, request, response);
try {
myBeanContext.getSingletonService(HttpDownloadProcessor.class).processDownload(new HttpDownloadProcessor.FileInfo() {
@Override
public long getLastModified() {
return FilesSubResource.getLastModified(element);
}
@Override
public long getFileSize() {
return element.getSize();
}
@Override
@NotNull
public String getFileName() {
return element.getName();
}
@Override
@NotNull
public String getFileDigest() {
// note: "aggregated" build artifacts are still not handled in due way here
return getETag(element, myUrlPrefix);
}
@Override
@NotNull
public InputStream getInputStream() throws IOException {
// todo: see this method in HttpDownloadProcessor
return element.getInputStream();
}
}, setContentDisposition, /*header is forced to attachment above*/
request, response);
} catch (IOException e) {
// todo add better processing
throw new OperationException("Error while processing file '" + element.getFullName() + "': " + e.toString(), e);
}
}
Aggregations