Restygwt download byte[]

200 Views Asked by At

I have only an array of byte on the client side. Another server send me JSON

{
 report - byte[]
}

I am looking for ways to save byte [] in browser

Send them to server or I can download from client side.

I can not find any solution at all.

So my question "Is it possible to save with restygwt byte [] an how???"

1

There are 1 best solutions below

0
André Onuki On

It is not possible to save the file directly from Resty.

https://github.com/resty-gwt/resty-gwt/issues/341

The most common workarounds to download files using AJAX are not using AJAX at all.

  • You can simply change the URL (using window.location) or (using javascript) create or;
  • create a form (using JS) and post that form.

In my projects, I simple create a URL to my REST endpoint attaching any query parameters needed and use it as the href to a link.

For instance, if your RestyGwt endpoint points to /entity/1/bytes just do

new Anchor("Download", "/entity/1/bytes");

your endpoint must produce a downloadable file type say:

@Produces("text/txt")