Learn.Archives/Learn.Archives.Core/Common/Expand/AlibabaCloudVodExpand.cs

57 lines
2.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AlibabaCloud.OpenApiClient.Models;
using AlibabaCloud.SDK.Vod20170321;
using AlibabaCloud.SDK.Vod20170321.Models;
using AlibabaCloud.TeaUtil.Models;
using Learn.Archives.Core.Common;
using Microsoft.Extensions.DependencyInjection;
namespace Learn.Archives.Core.Common.Expand
{
public class AlibabaCloudVodConfig
{
/// <summary>
/// id
/// </summary>
public string AccessKeyId { get; set; }
/// <summary>
///密钥
/// </summary>
public string AccessKeySecret { get; set; }
public string Endpoint { get; set; } = "vod.cn-shanghai.aliyuncs.com";
}
/// <summary>
/// 阿里云 视频点播拓展
/// </summary>
public static class AlibabaCloudVodExpand
{
/// <summary>
/// 使用阿里云 vod拓展
/// </summary>
/// <param name="service"></param>
/// <returns></returns>
public static void AddAlibabaCloudVod(this IServiceCollection service)
{
Console.WriteLine($"{DateTime.Now}=>初始化 阿里云VOD");
// 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
// 建议使用更安全的 STS 方式更多鉴权访问方式请参见https://help.aliyun.com/document_detail/378671.html。
Config config = new()
{
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
AccessKeyId = AppCommon.Config.AlibabaCloudVod.AccessKeyId,
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
AccessKeySecret = AppCommon.Config.AlibabaCloudVod.AccessKeySecret,
Endpoint = AppCommon.Config.AlibabaCloudVod.Endpoint
};
// Endpoint 请参考 https://api.aliyun.com/product/vod
var c = new Client(config);
service.AddSingleton(c);
}
}
}