I have a file as byte[]
in my gwt client side. I need to download the file. What should i do to achieve this?
Asked
Active
Viewed 1,029 times
2

Syam Kumar S
- 832
- 2
- 8
- 26
2 Answers
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
-
Can i do it from the client side only? Can you provide some codes. – Syam Kumar S Mar 06 '13 at 13:11
-
No we can't do it on client side.As per my knowledge its not possible.We have to send that bytes to server.You have to use either RPC or Core servlet. – Suresh Atta Mar 06 '13 at 13:27