Div | ||
---|---|---|
| ||
DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY (EXCEPT INSIDE THE DIV BELOW WITH ID=DESCRIPTION), UNLESS YOU KNOW WHAT YOU'RE DOING. |
Div | ||
---|---|---|
| ||
The File plugin provides functionality to work with files. Main features are:
When using the File plugin, it's important to take into account the differences and compatibility between different clients:
Many functions work only in the smart client or only on the server in the Headless or WebClient, some work in the WebClient's browser and that is mentioned in the doc (WebClient enabled) most of the time an extra parameter or some certain state must be set like a callback function, because in the WebClient the function will not wait for a result and then return the result, but will go on, and then the callback is called when it is done. (like showFileOpenDialog) Because the File plugin works with 3 different kind of files (LocalFiles on disk, RemoteFiles on the server when streaming is used and Uploaded files from the webclient when the browser uploads a file), not all things that you call on a JSFile object will give you data that you expect, for example a Uploaded file that you get back in the callback method of a showFileOpenDialog in the webclient does not represent an actual File object on the server. It is a binary data object (blob) that is only in memory, so getParentFile() or getPath() will return null in these cases, you don't get access or a reference to the file path or directory of the browsers pc. Also setBytes() will result in an exception. Best things to use is the getBytes() method if you want to get the bytes and store that, that will work for all 3 types. If you want to store the bytes that a webclient uploaded in another file the quickest way to do that is to use: var fileOnServer = plugins.file.convertToJSFile('/path/to/file/on/server'); plugins.file.writeFile(fileOnServer,uploadedFile.getBytes()); |
...