* @param io
* @throws GFacException
*/
public void uploadFile(URI destURI, GSSCredential gsCredential, InputStream io) throws ToolsException {
GridFTPClient ftpClient = null;
GridFTPContactInfo contactInfo = new GridFTPContactInfo(destURI.getHost(), destURI.getPort());
try {
String remoteFile = destURI.getPath();
log.info("The remote file is " + remoteFile);
log.debug("Setup GridFTP Client");
ftpClient = new GridFTPClient(contactInfo.hostName, contactInfo.port);
ftpClient.setAuthorization(new HostAuthorization(GridFtp.HOST));
ftpClient.authenticate(gsCredential);
ftpClient.setDataChannelAuthentication(DataChannelAuthentication.SELF);
makeFileTransferExternalConfigurations(null, ftpClient);
log.info("Uploading file");
if (checkBinaryExtensions(remoteFile)) {
log.debug("Transfer mode is set to Binary for a file upload");
ftpClient.setType(Session.TYPE_IMAGE);
}
ftpClient.put(remoteFile, new DataSourceStream(io), new MarkerListener() {
public void markerArrived(Marker marker) {
}
});
log.info("Upload file to:" + remoteFile + " is done");
} catch (ServerException e) {
throw new ToolsException("Cannot upload file to GridFTP:" + contactInfo.toString(), e);
} catch (IOException e) {
throw new ToolsException("Cannot upload file to GridFTP:" + contactInfo.toString(), e);
} catch (ClientException e) {
throw new ToolsException("Cannot upload file to GridFTP:" + contactInfo.toString(), e);
} finally {
if (ftpClient != null) {
try {
ftpClient.close();
} catch (Exception e) {