private void saveToRemoteHost(String filename)
{
URL remote_url = null;
Object[] speed_values = { "1", "2", "3", "4", "5", "10" };
RemoteSaveConfig remote_config = RemoteSaveConfig.getInstance();
String selected_value =
(String) JOptionPane.showInputDialog(null, RemoteSavePlugin.getI18n().getString("RemoteSaveSaveSWFActionTitle"), RemoteSavePlugin.getI18n().getString("RemoteSaveSaveSWFActionTitle"), JOptionPane.INFORMATION_MESSAGE, null, speed_values, speed_values[1]);
if (selected_value != null)
{
int speed = Integer.parseInt(selected_value);
FlashGenerator generator = new FlashGenerator(RemoteSavePlugin.getDrawingPanel().getCanvasSize(), speed);
File selected_file = new File(System.getProperty("java.io.tmpdir") + File.separator + filename);
generator.generateFile(selected_file.getPath(), RemoteSavePlugin.getDrawingPanel().getLines());
try
{
remote_url = new URL(remote_config.getProperty("remote_uri"));
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
MultipartPostMethod file_post = new MultipartPostMethod();
if (remote_url.getPath() == null)
{
file_post.setPath("/");
}
else
{
file_post.setPath(remote_url.getPath());
}
try
{
file_post.addParameter("swf", selected_file);
HttpClient client = new HttpClient();
client.getState().setCredentials("realm", new UsernamePasswordCredentials(remote_config.getProperty("remote_user"), remote_config.getProperty("remote_pwd")));
HostConfiguration hc = new HostConfiguration();
file_post.setDoAuthentication(true);
hc.setHost(new URI(remote_url));
client.setHostConfiguration(hc);
int status = client.executeMethod(file_post);