本文整理汇总了Java中org.kohsuke.stapler.StaplerResponse.serveFile方法的典型用法代码示例。如果您正苦于以下问题:Java StaplerResponse.serveFile方法的具体用法?Java StaplerResponse.serveFile怎么用?Java StaplerResponse.serveFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kohsuke.stapler.StaplerResponse
的用法示例。
在下文中一共展示了StaplerResponse.serveFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serveFile
import org.kohsuke.stapler.StaplerResponse; //导入方法依赖的package包/类
private void serveFile(File file, StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
// serve the file without Content-Security-Policy
long lastModified = file.lastModified();
long length = file.length();
try (InputStream in = new FileInputStream(file)) {
rsp.serveFile(req, in, lastModified, -1, length, file.getName());
}
}
开发者ID:web-innovate,项目名称:bootstraped-multi-test-results-report,代码行数:9,代码来源:SafeArchiveServingAction.java
示例2: doBrowse
import org.kohsuke.stapler.StaplerResponse; //导入方法依赖的package包/类
public void doBrowse(StaplerRequest request, StaplerResponse response) throws IOException
{
String requestedPath = FauxPasUtils.pathByRemovingLeadingSlash(request.getRestOfPath());
if (requestedPath == null)
response.sendError(404);
if (!APPROVED_REPORT_REQUEST_PATTERN.matcher(requestedPath).matches())
{
System.err.println("Someone is requesting unapproved content: " + requestedPath);
response.sendError(404);
return;
}
FilePath reportsPath = new FilePath(build.getRootDir());
FilePath requestedFilePath = new FilePath(reportsPath, FauxPasUtils.pathByRemovingLeadingSlash(requestedPath));
try
{
if (!requestedFilePath.exists())
{
System.err.println("Unable to locate report: " + request.getRestOfPath());
response.sendError(404);
return;
}
response.serveFile(request, requestedFilePath.toURI().toURL());
}
catch(Exception e)
{
System.err.println("FAILED TO SERVE FILE: " + request.getRestOfPath() + " -> " + e.getLocalizedMessage());
response.sendError(500);
}
}
示例3: doBuildScript
import org.kohsuke.stapler.StaplerResponse; //导入方法依赖的package包/类
public void doBuildScript(final StaplerRequest req, final StaplerResponse rsp) throws ServletException, IOException {
final InputStream file = new ByteArrayInputStream(getScript().getBytes(StandardCharsets.UTF_8));
rsp.serveFile(req, file, new Date().getTime(), 0, -1L, "dotci.sh");
}