I’ve got some Java Applet that I’d like to use to upload file/files to FTP server. Most important method is upload( String ftpServer, String username, String password, String filePath, File sourceFile ).
In JS code I’ve got stored in array data grabbed from input=”file” (user can attach and remove files to different objects he created before, so I have to store this data somewhere).
The problem is that file data is represented by JS File object, when calling upload function is recognized as sun.plugin2.main.client.MessagePassingJSObject (same thing when trying to initialize new java.io.File object).
So questions are:
is there possible to pass somehow object compatible with java.io.File or data about file (I guess only the fullpath) to Java applet ?
if not is there a way to upload from Java code file readed with FileReader to String (for example with .readAsBinaryString method) ?
or if exist any other solution for my problem ?
Edit:
A little more context:
Ftp upload applet is a part of application that uses canvas element (and fabric.js library to be specific). User after adding new elements to canvas area can choose an element and add/assing some files to that element (any image files). Images don’t have to be load into canvas area, just their names should appear on a list below canvas when specific element is selected. Of course they can be removed as well.
After user confirms that he finished some data is send (post) to server-side to prepare a control file, than upload this file to ftp server. The only information about selected files required in control file are filenames, so I think it’s possible to add file chooser to applet instead JS code, than send that data from applet or pass it to javascript and than send. Before or after posting control file data all files selected by user should be also uploaded to ftp server.
Unfortunately, there is one case when a file have to be loaded into canvas and send to ftp server as well after confirmation – background image file.
I don’t know any ways to pass HTML5-created ArrayBuffer to applet via Live Connect, but it is possible (and probably slightly more cross-browser compatible) to spawn Java file chooser and read file from disk, using applet (with JNLP FileOpenService you can do it without signing applet).