// 上传视频到media Server
private String doUpLoadVideo(File file, String fileName, String newPreName,
String destPath, String mmsPath) {
InputStream is;
try {
is = new FileInputStream(file);
String newFileName = "";
File savefile = null;
String ext = fileName.substring(fileName.lastIndexOf("."));
newFileName = newPreName + ext;
savefile = new File(new File(destPath), newFileName);
if (!savefile.getParentFile().exists()) {
savefile.getParentFile().mkdirs();
}
if (!savefile.getParentFile().exists()) {
return null;
}
OutputStream os = new FileOutputStream(savefile);
byte[] buffer = new byte[8192];
int count = 0;
while ((count = is.read(buffer)) > 0) {
os.write(buffer, 0, count);
}
os.close();
is.close();
return mmsPath + "/" + newFileName;
} catch (Exception e) {
// e.printStackTrace();
return null;
}
}
文件上传
最新推荐文章于 2024-02-29 11:08:48 发布