SftpServer: quick fix for spaces in filename

This commit is contained in:
2020-10-30 07:22:56 -05:00
parent 84e14a890f
commit 7a6e97a774

View File

@@ -28,6 +28,8 @@ public class SftpServer implements Server {
public URI upload (String name, ByteSource source) { public URI upload (String name, ByteSource source) {
try { try {
final URI target = URI.create(uri.toString() + "/" + name.replace(" ", "%20"));
final JSch jsch = new JSch(); final JSch jsch = new JSch();
final Session session = jsch.getSession(username, host, port); final Session session = jsch.getSession(username, host, port);
session.setPassword(password); session.setPassword(password);
@@ -45,7 +47,7 @@ public class SftpServer implements Server {
} }
session.disconnect(); session.disconnect();
return URI.create(uri.toString() + "/" + name); return target;
} catch (final JSchException | IOException | SftpException exception) { } catch (final JSchException | IOException | SftpException exception) {
throw new RuntimeException(exception); throw new RuntimeException(exception);
} }