是否有更有效的方式为音频文件与SpringBoot服务?
@RequestMapping(value = '/getSong/{id}', method = RequestMethod.GET)
def getMusic(HttpServletResponse response, @PathVariable Integer id) throws Exception {
Music m = shuffler.findTrackPathById(id)
if (m == null) {
return "File not found"
}
response.setContentType("audio/mpg")
response.setHeader("Content-disposition", "inline; filename=" + m.getFilename())
InputStream is = new FileInputStream(m.getFullpath())
FileCopyUtils.copy(is, response.getOutputStream())
response.getOutputStream().close()
}我每隔一段时间都会遇到这个错误:
2016-06-26 08:47:16.460 INFO 10831 --- [ Thread-11] o.e.jetty.server.handler.ContextHandler : Stopped o.s.b.c.e.j.JettyEmbeddedWebAppContext@ea9e141{/,file:/private/var/folders/73/gwl8bs6s4hgcl6vyln6_wzsc0000gn/T/jetty-docbase.7966202443679651433.8080/,UNAVAILABLE}
2016-06-26 08:47:46.463 WARN 10831 --- [ Thread-11] o.e.jetty.util.thread.QueuedThreadPool : qtp1041326823{STOPPING,8<=8<=200,i=0,q=1} Couldn't stop Thread[qtp1041326823-19,5,main]尽管我正在本地机器上进行测试,从一个角度应用程序发出的HTTP请求并不能立即下载该文件(速度为200‘t/s)。但是,如果我使用curl或者从地址栏下载它,它确实会立即被下载。
发布于 2017-01-15 11:16:33
问题是,我与其他资源(GET,POST)在同一个线程中提供音频文件。
https://stackoverflow.com/questions/38044992
复制相似问题