2. Upon any type of upload failure, show generic information for each failed upload and do not delete all file deployments. NO partial uploads allowed. |
All MIME types are being allowed as is an empty field for a file parameter. The code informs the user of failure for all of the files. If there is a failure (other than a blank field for a file parameter) then an error message is created that informs the user of individual file(s) that have failed to upload. The reasons for failure are given as a generic list.
XloadManager xman = new XloadManager(request); xman.target("file1", "uploaded1", 4096); xman.target("file2", "uploaded2", 4096); xman.target("file3", "uploaded3", 4096); xman.upload();
//deal with any failed int fieldBlank = 0; StringBuffer error = new StringBuffer(100); List failed = xman.getFailedFileUploads(); it = failed.iterator(); while(it.hasMore()){ upload = (XloadFileUpload)it.next(); String param = upload.getRequestParameter(); if(!upload.formFieldBlank()){ error.append(param + " failed to upload due to:" + //list possible reasons or give generic //message. + "\n"); }else{ fieldBlank++; } } if(fieldBlank == 3){ //return a response displaying that there have been //no files uploaded as all file fields are blank. }else{ //handle successful uploads List successful = xman.getSuccessfulFileUploads(); XloadFileUpload upload = null; Iterator it = successful.iterator(); while(it.hasMore()){ upload = (XloadFileUpload)it.next(); XloadFile file = upload.getFile(1); //place file details inside relational database }
//return a response using the error object as an error message //(i.e. some uploads have failed). }
|
© Gubutech(Xload) 2006 (v1.2)