验证中...
文件分片后端
Raw Copy
//省略分片文件上传,这里是将该文件的所有分片组合成完整文件
String[] arr = getParameter("names").split(",");
arr=Arrays.copyOf(arr, arr.length+1);//数组扩容
arr[arr.length-1]=uuid + prefix; //添加最后一块分片进入数组
String fileName = UUID.randomUUID().toString().toUpperCase().replaceAll("-", "");//最终文件名称
File lastFile = new File(getRealMasterVideo() + fileName + ".mp4");
out = new FileOutputStream(lastFile);
for(int i=0;i<arr.length;i++) {
File newFile = new File(getRealMasterVideo()+arr[i]);
in = new FileInputStream(newFile);
length = 0;
while (-1 != (length = in.read(img_buffer, 0, img_buffer.length))) {
out.write(img_buffer);
}
if (in != null) {
in.close();
}
//当前分片写入完成后删除该分片
if(newFile.exists()&&newFile.isFile()) {
newFile.delete();
}
}

Comment list( 0 )

You need to Sign in for post a comment

Help Search