×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jul 2010
    Posts
    6

    Problem with apibridge upload + flash lite + java servlet

    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:

    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;
    	}
    }
    And this is the servlet "doPost":

    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.

  2. #2
    Registered User
    Join Date
    Jul 2010
    Posts
    6

    Re: Problem with apibridge upload + flash lite + java servlet

    Can not anybody help me?

  3. #3
    Registered User
    Join Date
    Jul 2010
    Posts
    6

    Smile Re: Problem with apibridge upload + flash lite + java servlet

    Hi, I have found the solution.

    was missing set and send status to the client from the servlet:

    Code:
    		
    int status = HttpServletResponse.SC_OK;
    String statusText = "OK";
    response.setStatus(status);
    out.write(statusText );
    Greetings

Similar Threads

  1. Flash Lite 4 and ApiBridge
    By egomacher in forum [Archived] Flash Lite on Nokia Devices
    Replies: 8
    Last Post: 2011-03-08, 11:10
  2. I can't use the APIbridge in my flash lite application
    By zhanghequan in forum [Archived] Flash Lite on Nokia Devices
    Replies: 4
    Last Post: 2010-07-21, 07:16
  3. Problem with The getURL() method - Flash lite
    By itay99988 in forum [Archived] Flash Lite on Nokia Devices
    Replies: 1
    Last Post: 2010-07-20, 14:57
  4. Packing a Flash Lite Application with APIBridge
    By ranco in forum [Archived] Flash Lite on Nokia Devices
    Replies: 4
    Last Post: 2010-03-24, 14:52
  5. Problem with Flash Lite & Nokia - Flash Lite does not open in MMS
    By muggzy in forum [Archived] Flash Lite on Nokia Devices
    Replies: 4
    Last Post: 2008-12-17, 17:13

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •