Hi,

I'm trying to get an image from the database and I can't get the 
"ConnectionRequest" API to run (I see the webservice in debug mode and 
nothing moves). It's frustrating because I was able to upload the image 
without a problem, but I can't download it.

My code on the client:

public static void fetchFoto(SuccessCallback<Image> callback) {
        fetchFoto(usr.usuarioId.getLong(), callback);
    }

public static void fetchFoto(long usuarioId, SuccessCallback<Image> 
callback) {
        ConnectionRequest cr = new ConnectionRequest(SERVER_URL + 
"usuario/foto/" + usuarioId, false);
        cr.setFailSilently(true);
        cr.downloadImageToStorage("fotoImagen-" + usuarioId, callback);
    }

My code in the webservice

    
    @RequestMapping(value = "/foto/{usuarioId:.+}", method = 
RequestMethod.GET)
    public ResponseEntity<byte[]> getFoto(@PathVariable("usuarioId") Long 
usuarioId) {
        byte[] av = usuarios.getFoto(usuarioId);
        if(av != null) {
            return 
ResponseEntity.ok().contentType(MediaType.IMAGE_JPEG).body(av);
        }
        return ResponseEntity.notFound().build();
    }


    public byte[] getFoto(Long usuarioId) {
        Usuario u = usuarios.findOne(usuarioId);
        return u.getFoto();
//        return obtenImagenByte(u.getFoto());
    }


The variable SERVER_URL has the local address of the server and I rule out 
that it is wrong since it is used for all other connections to the server.

I must also clarify that I can see that the routine in the client is 
executed, but as I mentioned in the webservice the execution never arrives.

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to codenameone-discussions+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/f2db3847-a2fe-4872-b272-01d0b743b7a1n%40googlegroups.com.

Reply via email to