当前位置:网站首页>Tencent Cloud VOD uploads video files to solve the path problem
Tencent Cloud VOD uploads video files to solve the path problem
2022-08-06 07:54:00 【Youmans_station】
Tencent Cloud VOD needs,视频的路径.
思路一,MultipartFileGet the file path from the cache-失败
思路二,Store the horseshoe pat file stream locally,Then set the local path up.
废话少说,直接上代码.
//上传视频
@Override
public String uploadVideo(MultipartFile file) {
try {
VodUploadClient client =
new VodUploadClient(ConstantPropertiesUtil.ACCESS_KEY_ID,
ConstantPropertiesUtil.ACCESS_KEY_SECRET);
VodUploadRequest request = new VodUploadRequest();
// String fileName = UUID.randomUUID() + "." + originalFilename.split("\\.")[originalFilename.split("\\.").length - 1];
//Get the compiled file location
// File f = new File(this.getClass().getResource("/").getPath());
// String str = f.getPath() ;387702304156452066
// System.err.println(str);
// String bb= str.substring(0,str.lastIndexOf("target")) ;
//copyFile(inputStream,bb);
String fileName = file.getOriginalFilename();
fileName = UUID.randomUUID() + "." + fileName.split("\\.")[fileName.split("\\.").length - 1];
// Get local video location
this.tempVideoPath = File.listRoots()[1].getPath()+File.separator+"data"+File.separator;
File ff=new File(this.tempVideoPath);
if(!ff.exists()){
ff.mkdirs() ;
}
file.transferTo(new File(this.tempVideoPath + fileName));
String filePath = this.tempVideoPath+fileName;
System.out.println(this.tempVideoPath+fileName);
//视频本地地址
request.setMediaFilePath(filePath);
//指定任务流
request.setProcedure("LongVideoPreset");
//调用上传方法,传入接入点地域及上传请求.
VodUploadResponse response = client.upload("ap-guangzhou", request);
//返回文件id保存到业务表,用于控制视频播放
String fileId = response.getFileId();
System.out.println("Upload FileId = {}"+response.getFileId());
new File(filePath).delete();
return fileId;
} catch (Exception e) {
System.out.println(e.toString());
}
return null;
}
边栏推荐
- CobaltStrike图片远程上线(实验篇)
- 【愚公系列】2022年08月 Go教学课程 030-对象继承
- R语言统计与绘图:生存率的比较
- The origin of the name, concave language -, and moral
- 猴子都能上手的Unity插件Photon之重要部分(PUN)
- ggarchery包:在ggplot2图形上添加个性化箭头
- How to improve the quality of articles without being "recommended and affected" by the post assistant
- CPU Architecture at a Glance
- "Digital reconstruction system, CEO is the first step"
- 【leetcode】8. 字符串转换整数 (atoi)
猜你喜欢
随机推荐
《UnityShader入门精要》总结(1)理论篇
EsgynDB Troubleshooting - 网卡MTU导致跨网段访问数据库失败
Process finished with exit code -1073740791 (0xC0000409)
求助,关于json反序列化问题
dalle2:hierarchical text-conditional image generation with clip
Unity Xchart3.0基本用法快速上手
autoReg | 自动线性和逻辑回归和生存分析
Autumn begins tomorrow, the weather is getting cooler
unity 3D物体变换(旋转,缩放)
finalfit包可视化模型结果
DemographicTable 新的基线特征表绘制 R包
数据集ilpd印度肝病数据数据分析
js simulates the function of dynamically deleting messages
代码签名证书多少钱?
[科普文] 搞 Web3 要学习哪些基础知识?
CSDN官方插件
On-line project database properties added
从幻核疑似裁撤看如何保证NFT的安全
解决你的R语言乱码问题
限制命令长度如何反弹shell









