4. Upon any type of upload failure, show generic information for each failed upload and do not delete all file deployments. Partial uploads ARE being allowed.

 

back to examples

 

All MIME types are being allowed as is an empty field for a file parameter. The code informs the user of failure for any 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. Partial uploads are being allowed so the code will still deal with any successful uploads even if some severe IO Error occurs part way through uploading. A response is sent if a partial upload has occurred as the IO Error may have not involved the client/server connection.

 

 

 

XloadManager xman = new XloadManager(request, true);

xman.target("file1", "uploaded1", 4096);

xman.target("file2", "uploaded2", 4096);

xman.target("file3", "uploaded3", 4096);

xman.upload();

 

 

//deal with any failed

int fieldBlank = 0;

List failed = xman.getFailedFileUploads();

it = failed.iterator();

while(it.hasMore()){

String param = upload.getRequestParameter();

upload = (XloadFileUpload)it.next();

if(!upload.formFieldBlank()){

error.append(param + " failed to upload due to:" +

//list possible reasons or give generic

//message.

"\n");

}else{

fieldBlank++;

}

}

 

//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

}

 

if(xman.partialUploadOccurred()){

error.append("Your upload was interrupted therefore some " +

"uploads may not have been attempted.");

//could add to this a list of all uploads that

//were not attempted using the

//getRedundantTargetUploads() method. Most partial uploads

//occur with a breakdown in the client/server connection,

//so be pragmatic as most of the time information gathered

//here will be unused as a response cannot be sent.

}else if(fieldBlank == 3){

//return a response displaying that there have been

//no files uploaded as all file fields are blank.

}

//return a response using the error object as an error message

//(i.e. some uploads have failed).

 

 

 

back to examples

 

 

 

 

© Gubutech(Xload) 2006 (v1.2)