spring boot 阿里云视频点播 spring boot 实现阿里云视频点播功能(删除视频)
一起码代码 人气:0目录:
1.spring boot实现阿里云视频点播上传视频(复制粘贴即可)
2.spring boot 实现阿里云视频点播 --删除视频
导包和部分类在spring boot实现阿里云视频点播上传视频(复制粘贴即可)博客有说明,就不再重复了。
InitVodCilent
public class InitVodCilent { public static DefaultAcsClient initVodClient(String accessKeyId, String accessKeySecret) throws ClientException { String regionId = "cn-shanghai"; // 点播服务接入区域 DefaultProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret); DefaultAcsClient client = new DefaultAcsClient(profile); return client; } }
service
@Override public void removeMoreAlyVideo(List videoIdList) { try { //初始化对象 DefaultAcsClient client = InitVodCilent.initVodClient(ConstantVodUtils.ACCESS_KEY_ID, ConstantVodUtils.ACCESS_KEY_SECRET); //创建删除视频request对象 DeleteVideoRequest request = new DeleteVideoRequest(); //videoIdList值转换成 1,2,3 String videoIds = StringUtils.join(videoIdList.toArray(), ","); //向request设置视频id request.setVideoIds(videoIds); //调用初始化对象的方法实现删除 client.getAcsResponse(request); }catch(Exception e) { e.printStackTrace(); throw new EduException(20001,"删除视频失败"); } }
controller
//根据视频id删除阿里云视频 @DeleteMapping("removeAlyVideo/{id}") public R removeAlyVideo(@PathVariable String id) { try { //初始化对象 DefaultAcsClient client = InitVodCilent.initVodClient(ConstantVodUtils.ACCESS_KEY_ID, ConstantVodUtils.ACCESS_KEY_SECRET); //创建删除视频request对象 DeleteVideoRequest request = new DeleteVideoRequest(); //向request设置视频id request.setVideoIds(id); //调用初始化对象的方法实现删除 client.getAcsResponse(request); return "删除成功"; }catch(Exception e) { e.printStackTrace(); } } //删除多个阿里云视频的方法 //参数多个视频id List videoIdList @DeleteMapping("delete-batch") public R deleteBatch(@RequestParam("videoIdList") List<String> videoIdList) { vodService.removeMoreAlyVideo(videoIdList); return "删除成功"; }
加载全部内容