spring boot 實現(xiàn)阿里云視頻點播功能(刪除視頻)
目錄:
1.spring boot實現(xiàn)阿里云視頻點播上傳視頻(復制粘貼即可)
2.spring boot 實現(xiàn)阿里云視頻點播 --刪除視頻
導包和部分類在spring boot實現(xiàn)阿里云視頻點播上傳視頻(復制粘貼即可)博客有說明,就不再重復了。
InitVodCilent
public class InitVodCilent { public static DefaultAcsClient initVodClient(String accessKeyId, String accessKeySecret) throws ClientException { String regionId = 'cn-shanghai'; // 點播服務接入?yún)^(qū)域 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); //創(chuàng)建刪除視頻request對象 DeleteVideoRequest request = new DeleteVideoRequest(); //videoIdList值轉換成 1,2,3 String videoIds = StringUtils.join(videoIdList.toArray(), ','); //向request設置視頻id request.setVideoIds(videoIds); //調(diào)用初始化對象的方法實現(xiàn)刪除 client.getAcsResponse(request); }catch(Exception e) { e.printStackTrace(); throw new EduException(20001,'刪除視頻失敗'); } }
controller
//根據(jù)視頻id刪除阿里云視頻 @DeleteMapping('removeAlyVideo/{id}') public R removeAlyVideo(@PathVariable String id) { try { //初始化對象 DefaultAcsClient client = InitVodCilent.initVodClient(ConstantVodUtils.ACCESS_KEY_ID, ConstantVodUtils.ACCESS_KEY_SECRET); //創(chuàng)建刪除視頻request對象 DeleteVideoRequest request = new DeleteVideoRequest(); //向request設置視頻id request.setVideoIds(id); //調(diào)用初始化對象的方法實現(xiàn)刪除 client.getAcsResponse(request); return '刪除成功'; }catch(Exception e) { e.printStackTrace(); } } //刪除多個阿里云視頻的方法 //參數(shù)多個視頻id List videoIdList @DeleteMapping('delete-batch') public R deleteBatch(@RequestParam('videoIdList') List<String> videoIdList) { vodService.removeMoreAlyVideo(videoIdList); return '刪除成功'; }
到此這篇關于spring boot 實現(xiàn)阿里云視頻點播(刪除視頻功能)的文章就介紹到這了,更多相關spring boot 阿里云視頻點播內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持好吧啦網(wǎng)!
相關文章:
1. Java發(fā)送http請求的示例(get與post方法請求)2. JS繪圖Flot如何實現(xiàn)動態(tài)可刷新曲線圖3. springboot基于Redis發(fā)布訂閱集群下WebSocket的解決方案4. IDEA項目的依賴(pom.xml文件)導入問題及解決5. 基于android studio的layout的xml文件的創(chuàng)建方式6. CSS自定義滾動條樣式案例詳解7. 使用ProcessBuilder調(diào)用外部命令,并返回大量結果8. python使用requests庫爬取拉勾網(wǎng)招聘信息的實現(xiàn)9. HTML實現(xiàn)title 屬性換行小技巧10. python利用后綴表達式實現(xiàn)計算器功能
