What do you see in the network monitor in the simulator?
Notice that downloadImageToStorage won't do anything if the image is 
already downloaded!
That's the idea, it's smart enough to know that the image is already there 
and just send you the existing image. You can delete it from the ".cn1" 
directory to debug.

On Wednesday, May 19, 2021 at 3:49:05 AM UTC+3 [email protected] wrote:

> 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/a1f1feee-cf7d-42b2-806d-19a4b1fe8e0cn%40googlegroups.com.

Reply via email to