質問

This is my code for sending and image data over Errai Jax-RS:

    Model model = new Model();
    GWT.log("Before setting byte array");
    model.setImage(Base64.base64ToByteArray(base64)); 
    GWT.log("After setting byte array");
    modelService.call(new RemoteCallback<String>() {
        @Override
        public void callback(String hash) {
            GWT.log("Model upload with hash - " + hash);
        }
    }, new ErrorCallback() {
        @Override
        public boolean error(Message message, Throwable throwable) {
            showErrorModal();
            return false;
        }
    }).createModel(model);

The log shows that "After setting byte array" is logged before the client (browser) break, or hang. So the problem seems to be with the service call. Is it wrong to send base64 data like this? The test data send it about 350K bytes in size.

役に立ちましたか?

解決

I would send the image in String instead of in a byte array.

So change the image attribute in your model to String, and convert from base64 string to byte array in server side when you need to handle the image.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top