User-183185495 posted
What is my best way of returning that a document was failed to be uploaded Im using a helper class as I have 3 different upload methods to account for server , ftp and folder based.
Would I be best with my own object being returned in the task to detail the error from the exception method or would I be better with a proper IACTION result being returned.
public enum UploadType {
FTP=1,
FOLDER=2,
SERVER=3
}
public async Task<bool> FileUploadAysnc(FileAttachmentsVM fileAttachments,string savedFileName,string uniqueFilename, FileMode fileMode,UploadType uploadType) {
string ServerLocation = AppConfiguration.Instance.FileUploadPath;
try {
//this is only if the permission has correct permissions it should be either a map drive
// or a unc path with apporpiate user permissions
if (uploadType == UploadType.SERVER) {
await fileAttachments.File.CopyToAsync(new FileStream(savedFileName, FileMode.Create));
}
if (uploadType == UploadType.FOLDER) {
FileInfo infoFile = new FileInfo(uniqueFilename);
string extension = infoFile.Extension;
}
return true;
} catch (Exception ex) {
return false;
}
}