locked
Best way to return failed upload in mvc RRS feed

  • Question

  • 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;
        }
    
    
    
    }

    Friday, July 24, 2020 10:25 PM

All replies

  • User475983607 posted

    Depends on the client.  If it is a browser then returning a bool will show true/false in the browser.  

    Friday, July 24, 2020 10:31 PM
  • User-183185495 posted

    Yeah its just a web front end mvc

    Depends on the client.  If it is a browser then returning a bool will show true/false in the browser.  

    Saturday, July 25, 2020 1:50 PM