protected void doHandleUploadRequest ( final Request request ) { // Protect against client-side tampering of disabled/read-only fields. if ( isDisabled ( ) || isReadOnly ( ) ) { throw new SystemException ( "File widget cannot be updated." ) ; } // Only process on a POST if ( ! "POST" . equals ( request . getMethod ( ) ) ) { throw new SystemException ( "File widget cannot be updated by " + request . getMethod ( ) + "." ) ; } // Check only one file item in the request FileItem [ ] items = request . getFileItems ( getId ( ) ) ; if ( items . length > 1 ) { throw new SystemException ( "More than one file item received on the request." ) ; } // Check the client provided a fileID String fileId = request . getParameter ( FILE_UPLOAD_MULTI_PART_ID_KEY ) ; if ( fileId == null ) { throw new SystemException ( "No file id provided for file upload." ) ; } // Wrap the file item FileItemWrap wrap = new FileItemWrap ( items [ 0 ] ) ; // if fileType is supplied then validate it if ( hasFileTypes ( ) && ! FileUtil . validateFileType ( wrap , getFileTypes ( ) ) ) { String invalidMessage = FileUtil . getInvalidFileTypeMessage ( getFileTypes ( ) ) ; throw new SystemException ( invalidMessage ) ; } // if fileSize is supplied then validate it if ( hasMaxFileSize ( ) && ! FileUtil . validateFileSize ( wrap , getMaxFileSize ( ) ) ) { String invalidMessage = FileUtil . getInvalidFileSizeMessage ( getMaxFileSize ( ) ) ; throw new SystemException ( invalidMessage ) ; } FileWidgetUpload file = new FileWidgetUpload ( fileId , wrap ) ; addFile ( file ) ; // Set the file id to be used ion the renderer setFileUploadRequestId ( fileId ) ; setNewUpload ( true ) ; }
The request is a targeted file upload request . Upload the file and respond with the file information .