2

I have a file as byte[] in my gwt client side. I need to download the file. What should i do to achieve this?

Syam Kumar S
  • 832
  • 2
  • 8
  • 26

2 Answers2

1

Send Byte to server side using RPC call and write file there in to file.

BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(yourFile));
bos.write(byteArray);
bos.flush();
bos.close();
bNd
  • 7,512
  • 7
  • 39
  • 72
  • I dont need to write the file to a custom location. I only need to do download it with the file download dialog of the browser. – Syam Kumar S Mar 07 '13 at 10:23
  • @SyamKumarS if any hyperlinks to files that the user needs to execute on the local system, browser shows file download for security reason. so No, It is not possible in javascript beacuse JavaScript doesn't have access to writing files as this would be a huge security risk. – bNd Mar 07 '13 at 11:00
0

The Browser will not have access to save files to the users local drive;

Send bytes to server and Stream it

Community
  • 1
  • 1
Suresh Atta
  • 120,458
  • 37
  • 198
  • 307