您的位置:首頁技術文章
文章詳情頁

spring boot 實現阿里云視頻點播功能(刪除視頻)

瀏覽:66日期:2023-07-29 10:30:03

目錄:

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 阿里云視頻點播內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

標簽: Spring
相關文章:
国产综合久久一区二区三区