diff --git a/DataVAPI/Controllers/LogController.cs b/DataVAPI/Controllers/LogController.cs index ce65d4e..04b0b37 100644 --- a/DataVAPI/Controllers/LogController.cs +++ b/DataVAPI/Controllers/LogController.cs @@ -283,6 +283,31 @@ namespace DataVAPI.Controllers return JsonMsg.Error(null, st, ex.Message); } } - + /// + /// 删除日志文件 + /// + /// + /// + /// + [HttpGet] + public JsonMsg DeleteLogFile(string DeviceName, string FileId) + { + st = System.Reflection.MethodBase.GetCurrentMethod().Name; + try + { + if (string.IsNullOrEmpty(DeviceName)) + { + return JsonMsg.Error(null, st, "设备名称不能为空"); + } + else + { + return JsonMsg.OK(Sample.DeleteFile(DeviceName, FileId), st); + } + } + catch (Exception ex) + { + return JsonMsg.Error(null, st, ex.Message); + } + } } } diff --git a/DataVAPI/UpAndDown/Sample.cs b/DataVAPI/UpAndDown/Sample.cs index eb7d10c..edce463 100644 --- a/DataVAPI/UpAndDown/Sample.cs +++ b/DataVAPI/UpAndDown/Sample.cs @@ -72,6 +72,21 @@ namespace DataVAPI.UpAndDown return queryDeviceFile; } + public static bool? DeleteFile(string DeviceName, string FileId) + { + AlibabaCloud.SDK.Iot20180120.Client client = CreateClient("LTAI5tDbUDuCvqU5hP8ZpHHV", "SvNIRQuz3BQFEaC3PFSJdgpeOKWFRi"); + AlibabaCloud.SDK.Iot20180120.Models.DeleteDeviceFileRequest deleteDeviceFileRequest = new AlibabaCloud.SDK.Iot20180120.Models.DeleteDeviceFileRequest + { + IotInstanceId = "iot-06z00g9pf3kwtxp", + DeviceName = DeviceName, + ProductKey = DataBus.ProductKey, + FileId = FileId, + }; + AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions(); + // 复制代码运行请自行打印 API 的返回值 + return client.DeleteDeviceFileWithOptions(deleteDeviceFileRequest, runtime).Body.Success; + } + } public class AlibabaCloudRes