spring boot 實現(xiàn)阿里云視頻點播功能(刪除視頻)
目錄:
1.spring boot實現(xiàn)阿里云視頻點播上傳視頻(復(fù)制粘貼即可)
2.spring boot 實現(xiàn)阿里云視頻點播 --刪除視頻
導(dǎo)包和部分類在spring boot實現(xiàn)阿里云視頻點播上傳視頻(復(fù)制粘貼即可)博客有說明,就不再重復(fù)了。
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)文章
Mybatis-Plus設(shè)置全局或者局部ID自增的實現(xiàn)
在使用Mybatis-Plus新增的時候,我們往往想要id隨著數(shù)據(jù)庫自增,本文主要介紹了Mybatis-Plus設(shè)置全局或者局部ID自增的實現(xiàn),具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-01-01
Spring中的@PostConstruct注解使用方法解析
這篇文章主要介紹了Spring中的@PostConstruct注解使用方法解析,@PostConstruct注解是用來處理在@Autowired注入屬性后init()方法之前,對一些零散的屬性進行賦值的注解,需要的朋友可以參考下2023-11-11
SpringBoot3.x集成nacos并實現(xiàn)多環(huán)境配置的操作步驟
本文詳細介紹了如何在Springboot3.x中集成Nacos2.x版本,包括nacos的安裝、配置更改,以及在集成過程中遇到的問題,如端口設(shè)置、依賴版本調(diào)整等,文中通過圖文介紹的非常詳細,需要的朋友可以參考下2024-10-10
簡單捋捋@RequestParam 和 @RequestBody的使用
這篇文章主要介紹了簡單捋捋@RequestParam 和 @RequestBody的使用,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-12-12

