0
私はスプリングブートを使用してmp4ビデオを返そうとしています。 私はlocalhsotを使用して、コントローラのメソッドにアクセスするときに問題がある:localhostが127.0.0.1またはローカルIPと異なるコンテンツを返します
http://localhsot:8080/files/videos/mission0.mp4
それは返す:
Content-Type →video/mp4
Date →Thu, 11 Aug 2016 17:41:30 GMT
Transfer-Encoding →chunked
X-Application-Context →application
と、ブラウザで再生映像、 私は127.0.0.1またはローカルIPを使用しますlocalhostの代わりに返されます。
Cache-Control →no-cache
Connection →close
Pragma →no-cache
ビデオは返されません。あなたは、コマンドプロンプトを開き
@RequestMapping(value="/videos/{fileName:.+}")
public void getVideo(HttpServletResponse response, @PathVariable("fileName") String fileName) {
byte[] video = fileService.getFileBytes(videoDir, fileName);
ByteInputStream videoStream = new ByteInputStream(video, video.length);
try {
response.setHeader("Content-Type", "video/mp4");
IOUtils.copy(videoStream, response.getOutputStream());
} catch (IOException e) {
throw new InternalServerErrorException("Error while rendering the video");
}
}
要求が行われたときに 'localhost'がループバックIPに変換されるので、ループバックが機能していなければなりません。 –
うまく動作していて、他のapiエンドポイント(jsonや画像を返す)が正常に動作しています。 – Ward
@ShawnClarkあなたのマシン上のコードを試してみてください。 – Ward