Пример #1
0
        /// <summary>
        /// 询问服务器,文件是否存在
        /// </summary>
        /// <param name="fileId">要询问的文件信息</param>
        /// <param name="success">成功回调函数</param>
        /// <param name="failure">失败回调函数</param>
        /// <returns>文件是否已经存在</returns>
        public static void IsFileExistInServer(string fileId, Success <bool> success, Failure failure = null)
        {
            var restTemplate = new RestTemplate();

            restTemplate.MessageConverters.Add(new NJsonHttpMessageConverter());
            restTemplate.HeadForHeadersAsync(Resources.fileInfoUrl + "/" + fileId, resp =>
            {
                if (resp.Error != null)
                {
                    failure?.Invoke(resp.Error.Message);
                }
                else
                {
                    var singleValue = resp.Response.GetSingleValue("isExist");
                    success?.Invoke(!string.IsNullOrWhiteSpace(singleValue) && singleValue.ToUpper().Equals("TRUE"));
                }
            });
        }