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"; // 點播服務(wù)接入?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值轉(zhuǎn)換成 1,2,3 String videoIds = StringUtils.join(videoIdList.toArray(), ","); //向request設(shè)置視頻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設(shè)置視頻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 "刪除成功"; }
到此這篇關(guān)于spring boot 實現(xiàn)阿里云視頻點播(刪除視頻功能)的文章就介紹到這了,更多相關(guān)spring boot 阿里云視頻點播內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
如何解決SpringBoot2.x版本對Velocity模板不支持的方案
這篇文章主要介紹了如何解決SpringBoot2.x版本對Velocity模板不支持的方案,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-12-12Java數(shù)據(jù)結(jié)構(gòu)之散列表詳解
散列表(Hash table,也叫哈希表),是根據(jù)關(guān)鍵碼值(Key value)而直接進行訪問的數(shù)據(jù)結(jié)構(gòu)。本文將為大家具體介紹一下散列表的原理及其代碼實現(xiàn)2022-01-01