37 lines
1.4 KiB

using COSSTS;
using Newtonsoft.Json;
using Znyc.CloudCar.Configuration;
using Znyc.CloudCar.IServices.Document;
using Znyc.CloudCar.Model.Dtos.Document;
using Znyc.CloudCar.Model.ViewModels.ReportsCallBack;
namespace Znyc.CloudCar.Services.Document
{
public class DocumentService : IDocumentService
{
/// <summary>
/// 上传图片
/// </summary>
/// <returns></returns>
public ResponseOutput UploadImageAsync()
{
Dictionary<string, object> values = new()
{
["bucket"] = AppSettingsConstVars.CosConfigBucket,
["region"] = AppSettingsConstVars.CosConfigRegion,
["allowPrefix"] = AppSettingsConstVars.CosConfigAllowPrefix,
["allowActions"] = AppSettingsConstVars.CosConfigAllowActions,
["durationSeconds"] = AppSettingsConstVars.CosConfigDurationSeconds,
["secretId"] = AppSettingsConstVars.CosConfigSecretId,
["secretKey"] = AppSettingsConstVars.CosConfigSecretKey
};
Dictionary<string, object> credential = STSClient.genCredential(values);
return new ResponseOutput()
{
Data = JsonConvert.DeserializeObject<ImageOutput>(JsonConvert.SerializeObject(credential)),
Successed = true,
Code = 1
};
}
}
}