Hello,
I have a little problem with apibridge upload and flash lite.
On the server side I implemented a servlet that handles the storage of file and everything works properly, the file is stored on the server, but the callback function on the flash side is never executed and always remains on hold. I think I'm missing something on the server, but not that.
There is de flash code:
And this is the servlet "doPost":Code://Funcion que sube un fichero al servidor mediante APIBridge function fileUpload(filePath:String){ textoEstado.text = "Subiendo fichero con imagen: " + filePath.toString(); pathUpload = filePath.toString(); var inParams:Object = new Object(); inParams.VarName = "file"; inParams.FileName = filePath.toString(); inParams.Url = rutaDelServidor; bridge.UploadFile(inParams,onFileUpload); } //Callback del fileUpload function onFileUpload (transactionID:Number, eventID:String, outParam:Object) { if (outParam.ErrorCode != 0){ textoEstado.text = "Ocurrió un error " + outParam.ErrorCode + " en la subida del fichero (" + pathUpload + ")"; return; } else { textoEstado.text = "Descarga correcta de fichero."; pasarEstadoAJavaScript(pathFotografia); return; } }
Code:protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String realPathTemporal = getServletContext().getRealPath(TMP_DIR_PATH); File tmpDir = new File(realPathTemporal); if(!tmpDir.isDirectory()) { throw new ServletException(TMP_DIR_PATH + " no es un directorio"); } String realPathDestino = getServletContext().getRealPath(DESTINATION_DIR_PATH); File destinationDir = new File(realPathDestino); if(!destinationDir.isDirectory()) { throw new ServletException(DESTINATION_DIR_PATH + " no es un directorio"); } PrintWriter out = response.getWriter(); response.setContentType("text/html"); DiskFileItemFactory fileItemFactory = new DiskFileItemFactory (); //Umbral de tamaño, por encima del cual el contenido se almacena en el disco. fileItemFactory.setSizeThreshold(5*1024*1024); //5 MB //Directorio temporal para almacenar ficheros por encima del umbral fileItemFactory.setRepository(tmpDir); ServletFileUpload uploadHandler = new ServletFileUpload(fileItemFactory); try { //Analiza la solicitud List items = uploadHandler.parseRequest(request); for (Iterator iterator = items.iterator(); iterator.hasNext();) { FileItem item = (FileItem) iterator.next(); if(item.isFormField()) { //Se controlan los campos de formulario if (log.isInfoEnabled()) log.info("Nombre del campo...:" + item.getFieldName()); } else { //Se manejan los ficheros a subir if (log.isInfoEnabled()) log.info("Nombre de fichero..:" + item.getName()); //Se escribe el fichero al directorio de destino File fichero = new File(item.getName()); String nombreFichero = fichero.getName(); File file = new File(destinationDir, nombreFichero); item.write(file); } out.close(); } }catch(FileUploadException ex) { log("Error encotrado durante el analisis de solititud. ",ex); } catch(Exception ex) { log("Error encontrado durante la descarga del fichero. ",ex); } }
thank you very much for your help.




