Browse Source

增加删除文件接口

master
fyf 2 years ago
parent
commit
43b3756b12
2 changed files with 41 additions and 1 deletions
  1. +26
    -1
      DataVAPI/Controllers/LogController.cs
  2. +15
    -0
      DataVAPI/UpAndDown/Sample.cs

+ 26
- 1
DataVAPI/Controllers/LogController.cs View File

@@ -283,6 +283,31 @@ namespace DataVAPI.Controllers
return JsonMsg<object>.Error(null, st, ex.Message);
}
}

/// <summary>
/// 删除日志文件
/// </summary>
/// <param name="DeviceName"></param>
/// <param name="FileId"></param>
/// <returns></returns>
[HttpGet]
public JsonMsg<object> DeleteLogFile(string DeviceName, string FileId)
{
st = System.Reflection.MethodBase.GetCurrentMethod().Name;
try
{
if (string.IsNullOrEmpty(DeviceName))
{
return JsonMsg<object>.Error(null, st, "设备名称不能为空");
}
else
{
return JsonMsg<object>.OK(Sample.DeleteFile(DeviceName, FileId), st);
}
}
catch (Exception ex)
{
return JsonMsg<object>.Error(null, st, ex.Message);
}
}
}
}

+ 15
- 0
DataVAPI/UpAndDown/Sample.cs View File

@@ -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


Loading…
Cancel
Save