*/
public static final Any ftpPut(String urlString, Any anyData, int type)
throws IOException, UnserializationException
{
FtpURL ftpURL = new FtpURL(urlString);
FtpClient ftpClient = new FtpClient(ftpURL.host);
ftpClient.login(ftpURL.user,ftpURL.pass);
ftpClient.binary();
ftpClient.cd(ftpURL.dir);
BufferedWriter writer;
Any result;
switch (type) {
case StreamUtils.TYPE_STRING:
writer = new BufferedWriter(new OutputStreamWriter(ftpClient.put(ftpURL.file)));
writer.write(anyData.toString());
writer.close();
result = Any.TRUE;
break;
case StreamUtils.TYPE_LINES:
writer = new BufferedWriter(new OutputStreamWriter(ftpClient.put(ftpURL.file)));
result = StreamUtils.linesToWriter(anyData,writer);
break;
case StreamUtils.TYPE_BINARY:
OutputStream out = ftpClient.put(ftpURL.file);
byte[] byteArray = (byte[])(anyData.toObject());
out.write(byteArray);
out.close();
result = Any.TRUE;
break;
case StreamUtils.TYPE_DATA:
OutputStream outs = ftpClient.put(ftpURL.file);
Serialization.serialize(null, anyData, outs);
outs.close();
result = Any.TRUE;
break;
default:
result = Any.FALSE;
break;
}
try {
ftpClient.closeServer();
} catch (Exception e) {
//anvil.Log.log().error("Can not close ftp connection");
}
return result;
}