public string UploadFile(byte[] fileBytes, string fileName) { var strArr = fileName.Split('.'); if (strArr.Length < 2) { throw new ArgumentException(nameof(fileName)); } var fileNameBuilder = new StringBuilder(); for (var i = 0; i < strArr.Length - 1; i++) { fileNameBuilder.Append(strArr[i]); } var file = fileNameBuilder.ToString(); var fileExt = strArr.Last(); if (string.IsNullOrWhiteSpace(file) || string.IsNullOrWhiteSpace(fileExt)) { throw new ArgumentException(nameof(fileName)); } var storageNode = _fastDfsClient.GetStorageNode(_groupName); var fileDfsInfo = new FileDfsInfo { Id = Guid.NewGuid(), DfsFileName = _fastDfsClient.UploadFile(storageNode, fileBytes, fileExt), FileName = fileName, UtcCreateTime = DateTime.Now }; _repository?.Add(fileDfsInfo); return(fileDfsInfo.DfsFileName); }
public void GetStorageNode(string groupName) { var storageNode = _client.GetStorageNode(groupName); var endPoint = storageNode.EndPoint; var nodeGroupName = storageNode.GroupName; Assert.Contains(endPoint.Address.ToString(), new List <string> { "192.168.78.153", "192.168.78.154", "192.168.78.155" }); Assert.Equal(nodeGroupName, groupName); }