From 708734b76be925df22a589bdc76d6fe5e5ff0445 Mon Sep 17 00:00:00 2001 From: fyf Date: Mon, 23 May 2022 17:03:35 +0800 Subject: [PATCH] erere --- DataVAPI/UpAndDown/Sample.cs | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/DataVAPI/UpAndDown/Sample.cs b/DataVAPI/UpAndDown/Sample.cs index ad2bda2..f3a49bd 100644 --- a/DataVAPI/UpAndDown/Sample.cs +++ b/DataVAPI/UpAndDown/Sample.cs @@ -43,8 +43,7 @@ namespace DataVAPI.UpAndDown }; AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions(); AlibabaCloud.SDK.Iot20180120.Models.QueryDeviceFileListResponse resp = client.QueryDeviceFileListWithOptions(queryDeviceFileListRequest, runtime); - //AlibabaCloud.TeaConsole.Client.Log(); - //; + AlibabaCloudRes cloudRes= Tools.JsonToObjectTools(AlibabaCloud.TeaUtil.Common.ToJSONString(resp.ToMap())); cloudRes?.body?.Data?.FileSummary?.ForEach(fileSummary => { @@ -52,12 +51,43 @@ namespace DataVAPI.UpAndDown if (_data != null) { _data.UtcCreatedOn = DateTime.Parse(_data.UtcCreatedOn).AddHours(8).ToString("yyyy-MM-dd HH:mm:ss"); + _data.DownloadUrl = CutStarStr(_data.DownloadUrl,"http://","https://"); retdata.Add(_data); } }); return retdata; } - + /// + /// 替换字符串起始位置(开头)中指定的字符串 + /// + /// 源串 + /// 查找的串 + /// 替换的目标串 + /// + public static string CutStarStr(string s, string searchStr, string replaceStr) + { + var result = s; + try + { + if (string.IsNullOrEmpty(result)) + { + return result; + } + if (s.Length < searchStr.Length) + { + return result; + } + if (s.IndexOf(searchStr, 0, searchStr.Length, StringComparison.Ordinal) > -1) + { + result = s.Substring(searchStr.Length); + } + return result; + } + catch (Exception e) + { + return result; + } + } public static QueryDeviceFileResponseBodyData FileQuery(string DeviceName,string FileId) { AlibabaCloud.SDK.Iot20180120.Client client = CreateClient("LTAI5tDbUDuCvqU5hP8ZpHHV", "SvNIRQuz3BQFEaC3PFSJdgpeOKWFRi");