spring boot 實現阿里雲視訊點播功能(刪除視訊)
阿新 • • 發佈:2020-12-08
目錄:
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 "刪除成功"; }
到此這篇關於spring boot 實現阿里雲視訊點播(刪除視訊功能)的文章就介紹到這了,更多相關spring boot 阿里雲視訊點播內容請搜尋我們以前的文章或繼續瀏覽下面的相關文章希望大家以後多多支援我們!