GWT Toolkit: preprocessing files on client side

假如想象 提交于 2019-12-12 19:59:26

问题


If there's a way for the client side GWT code to pre-process a file on the client computer? For example, to calculate a checksum of it before submitting the file to the server.


回答1:


No it is not possible. The manipulation of the file is done by the browser, not the HTML code.

Think about it, GWT is 100% javascript. And javascript has no access whatsoever of the file in your computer. That would be an pretty big security risk! GWT "wraps" the file input box so it can be displayed inside the GWT panel. But once you press the "upload" button, the upload is done by the browser.

You could do file manipulation with another technology however. Java applets for example. But that is outside of GWT area...




回答2:


Using GWT, there is no way to read files on the client side yet. However, in HTML5, you can read files without uploading to a server using the "File API".

Links are provided below.

File API tutorial on html5rocks.com

Example of how to use File API in GWT via JSNI




回答3:


I'm pretty sure that because GWT code compiles to pure JavaScript, there isn't a way without requiring some third-party browser plugin.




回答4:


Do you mean from an <input type="file"...> file upload field in a form?

The short answer is no-- file uploads are handled by the browser, and are sent directly to the server (as an ENCODING_MULTIPART POST). And security restrictions on JavaScript mean there's no way to workaround that restriction.



来源:https://stackoverflow.com/questions/490062/gwt-toolkit-preprocessing-files-on-client-side

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!