public static string UploadFile(byte[] buffer, string extension, string fileName, string uploadDomain) { var result = string.Empty; try { if (buffer != null && !string.IsNullOrEmpty(extension) && !string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(uploadDomain)) { using (var client = new FileUploadClient()) { var getResult = client.UploadFile(new FileUploadRequest() { Contents = buffer, DirectoryName = uploadDomain, Extension = extension }); getResult.ThrowIfException(true); if (getResult.Success && getResult.Exception == null) { result = getResult.Result; buffer = null; } } } } catch (Exception ex) { logger.Error(ex); } return(result); }
public static string UploadImage(this byte[] buffer, string uploadDomain, string extension) { using (var client = new FileUploadClient()) { var getResult = client.UploadFile(new FileUploadRequest() { Contents = buffer, DirectoryName = uploadDomain, Extension = extension }); getResult.ThrowIfException(true); if (getResult.Success && getResult.Exception == null) { buffer = null; return(getResult.Result); } } return(null); }