67,549
社区成员




localhost:8080/upload/1.mp4
就直接可以播放的,但是因为需求需要把src路径改成这种localhost:8080/getvideo?moviename='1.mp4'
然后在后台通过请求接受到视频文件参数 ,通过BufferedOutputStream 输出流 传到前台 。byte[] buff = new byte[2046];
@Override
public void imgForword(String url, HttpServletRequest req, HttpServletResponse resp) throws IOException {
S3Object object = S3Handler.getInstance().getObject(S3Handler.smallPoolName, url);
S3ObjectInputStream objectInput = object.getObjectContent();
ByteArrayOutputStream output = new ByteArrayOutputStream();
byte[] buff = new byte[2046];
int rc = 0;
byte[] downByte = null;
while (-1 !=(rc = objectInput.read(buff))){
output.write(buff, 0, rc);
}
output.flush();
downByte = output.toByteArray();
output.close();
object.close();
OutputStream outStream=null;
BufferedOutputStream bufferOut =null;
try {
outStream = resp.getOutputStream();
bufferOut = new BufferedOutputStream(outStream);
bufferOut.write(downByte);
bufferOut.flush();
} catch (IOException e) {
e.printStackTrace();
}finally{
try {
outStream.close();bufferOut.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}