Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,11 @@ public static Object getFirst(Environment env, BObject clientConnector, BString
*/
@Deprecated
public static Object get(BObject clientConnector) {
return FtpClientHelper.generateInputStreamEntry((InputStream) clientConnector.getNativeData(READ_INPUT_STREAM));
InputStream inputStream = (InputStream) clientConnector.getNativeData(READ_INPUT_STREAM);
if (inputStream == null) {
return FtpUtil.createError("Error while reading the file: ftp client is closed", FTP_ERROR);
}
return FtpClientHelper.generateInputStreamEntry(inputStream);
}

public static Object getBytes(Environment env, BObject clientConnector, BString filePath) {
Expand Down Expand Up @@ -244,7 +248,12 @@ public static Object getBytesAsStream(Environment env, BObject clientConnector,
VfsClientConnectorImpl connector = (VfsClientConnectorImpl) clientConnector.
getNativeData(VFS_CLIENT_CONNECTOR);
connector.addListener(connectorListener);
connector.send(null, FtpAction.GET, filePath.getValue(), null);
try {
connector.send(null, FtpAction.GET, filePath.getValue(), null);
} catch (Exception exception) {
balFuture.complete(FtpUtil.createError("Error while reading the file: "
+ exception.getMessage(), exception, FTP_ERROR));
}
return getResult(balFuture);
});
}
Expand All @@ -261,7 +270,12 @@ public static Object getCsvAsStream(Environment env, BObject clientConnector, BS
VfsClientConnectorImpl connector = (VfsClientConnectorImpl) clientConnector.
getNativeData(VFS_CLIENT_CONNECTOR);
connector.addListener(connectorListener);
connector.send(null, FtpAction.GET, filePath.getValue(), null);
try {
connector.send(null, FtpAction.GET, filePath.getValue(), null);
} catch (Exception exception) {
balFuture.complete(FtpUtil.createError("Error while reading the file: "
+ exception.getMessage(), exception, FTP_ERROR));
}
return getResult(balFuture);
});
}
Expand All @@ -275,7 +289,12 @@ private static Object getAllContent(Environment env, BObject clientConnector, BS
VfsClientConnectorImpl connector = (VfsClientConnectorImpl) clientConnector.
getNativeData(VFS_CLIENT_CONNECTOR);
connector.addListener(connectorListener);
connector.send(null, FtpAction.GET_ALL, filePath.getValue(), null);
try {
connector.send(null, FtpAction.GET_ALL, filePath.getValue(), null);
} catch (Exception exception) {
balFuture.complete(FtpUtil.createError("Error while reading the file: "
+ exception.getMessage(), exception, FTP_ERROR));
}
return getResult(balFuture);
});
}
Expand Down Expand Up @@ -371,7 +390,12 @@ public static Object put(Environment env, BObject clientConnector, BMap<Object,
if (compressInput) {
filePath = FtpUtil.getCompressedFileName(filePath);
}
connector.send(message, FtpAction.PUT, filePath, null);
try {
connector.send(message, FtpAction.PUT, filePath, null);
} catch (Exception exception) {
balFuture.complete(FtpUtil.createError("Error while sending the file: "
+ exception.getMessage(), exception, FTP_ERROR));
}
return getResult(balFuture);
});
try {
Expand Down Expand Up @@ -567,10 +591,15 @@ private static Object putGenericAction(Environment env, BObject clientConnector,
= (VfsClientConnectorImpl) clientConnector.getNativeData(VFS_CLIENT_CONNECTOR);
connector.addListener(connectorListener);
String filePath = path.getValue();
if (options.getValue().equals(FtpConstants.WRITE_OPTION_OVERWRITE)) {
connector.send(message, FtpAction.PUT, filePath, null);
} else {
connector.send(message, FtpAction.APPEND, filePath, null);
try {
if (options.getValue().equals(FtpConstants.WRITE_OPTION_OVERWRITE)) {
connector.send(message, FtpAction.PUT, filePath, null);
} else {
connector.send(message, FtpAction.APPEND, filePath, null);
}
} catch (Exception exception) {
balFuture.complete(FtpUtil.createError("Error while sending the file: "
+ exception.getMessage(), exception, FTP_ERROR));
}
return getResult(balFuture);
});
Expand Down