腾讯云云点播删除视频源文件nodejs版

怼烎@ 2022-09-10 00:09 354阅读 0赞

首先,安装express框架,目的,使用express框架请求,方便快捷

参考 https://www.npmjs.com/package/express

创建 index.js

  1. const express = require('express')
  2. const app = express()
  3. const txSdk = require('./txsdk')
  4. app.get('/deleteTxMedia', function (req, res) {
  5. txSdk.deleteTxMedia(req.query.videoid, function (result) {
  6. res.send(result)
  7. })
  8. })
  9. app.listen(81)

txsdk.js

  1. const appid=;
  2. const secretId="";
  3. const secretKey="";
  4. const region="ap-beijing";
  5. const tencentcloud = require("tencentcloud-sdk-nodejs");
  6. // 导入对应产品模块的client models。
  7. const VodClient = tencentcloud.vod.v20180717.Client
  8. const clientConfig = {
  9. // 腾讯云认证信息
  10. credential: {
  11. secretId: secretId,
  12. secretKey: secretKey,
  13. },
  14. // 产品地域
  15. region: region,
  16. // 可选配置实例
  17. profile: {
  18. signMethod: "HmacSHA256", // 签名方法
  19. httpProfile: {
  20. reqMethod: "POST", // 请求方法
  21. reqTimeout: 30, // 请求超时时间,默认60s
  22. },
  23. },
  24. }
  25. // 实例化要请求产品(以cvm为例)的client对象
  26. const client = new VodClient(clientConfig)
  27. // 通过client对象调用想要访问的接口,需要传入请求对象以及响应回调函数
  28. /**
  29. * 删除媒体及其对应的视频处理文件
  30. * @param videoId
  31. */
  32. const deleteTxMedia = function (videoId,callback) {
  33. client.DeleteMedia({
  34. FileId: videoId,
  35. DeleteParts:[{Type:'OriginFiles'}]
  36. }, function (err, response) {
  37. if (err) {
  38. // console.error("error", err)
  39. callback(response)
  40. } else {
  41. // console.log(response)
  42. callback(response)
  43. }
  44. })
  45. }
  46. module.exports = {
  47. deleteTxMedia
  48. }

访问域名:81/deleteTxMedia?videoid=

发表评论

表情:
评论列表 (有 0 条评论,354人围观)

还没有评论,来说两句吧...

相关阅读