mirror of https://github.com/apache/nifi.git
NIFI-4137: Add support for UTF-8 in GetFTP and PutFTP
Signed-off-by: Yolanda M. Davis <ymdavis@apache.org> This closes #1957
This commit is contained in:
parent
c99c036c20
commit
9bfa7469cb
|
@ -81,6 +81,7 @@ public class GetFTP extends GetFileTransfer {
|
||||||
properties.add(FTPTransfer.PROXY_PORT);
|
properties.add(FTPTransfer.PROXY_PORT);
|
||||||
properties.add(FTPTransfer.HTTP_PROXY_USERNAME);
|
properties.add(FTPTransfer.HTTP_PROXY_USERNAME);
|
||||||
properties.add(FTPTransfer.HTTP_PROXY_PASSWORD);
|
properties.add(FTPTransfer.HTTP_PROXY_PASSWORD);
|
||||||
|
properties.add(FTPTransfer.UTF8_ENCODING);
|
||||||
this.properties = Collections.unmodifiableList(properties);
|
this.properties = Collections.unmodifiableList(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,7 @@ public class PutFTP extends PutFileTransfer<FTPTransfer> {
|
||||||
properties.add(FTPTransfer.PROXY_PORT);
|
properties.add(FTPTransfer.PROXY_PORT);
|
||||||
properties.add(FTPTransfer.HTTP_PROXY_USERNAME);
|
properties.add(FTPTransfer.HTTP_PROXY_USERNAME);
|
||||||
properties.add(FTPTransfer.HTTP_PROXY_PASSWORD);
|
properties.add(FTPTransfer.HTTP_PROXY_PASSWORD);
|
||||||
|
properties.add(FTPTransfer.UTF8_ENCODING);
|
||||||
|
|
||||||
this.properties = Collections.unmodifiableList(properties);
|
this.properties = Collections.unmodifiableList(properties);
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,6 +105,15 @@ public class FTPTransfer implements FileTransfer {
|
||||||
.required(false)
|
.required(false)
|
||||||
.sensitive(true)
|
.sensitive(true)
|
||||||
.build();
|
.build();
|
||||||
|
public static final PropertyDescriptor UTF8_ENCODING = new PropertyDescriptor.Builder()
|
||||||
|
.name("ftp-use-utf8")
|
||||||
|
.displayName("Use UTF-8 Encoding")
|
||||||
|
.description("Tells the client to use UTF-8 encoding when processing files and filenames. If set to true, the server must also support UTF-8 encoding.")
|
||||||
|
.required(true)
|
||||||
|
.allowableValues("true", "false")
|
||||||
|
.defaultValue("false")
|
||||||
|
.addValidator(StandardValidators.BOOLEAN_VALIDATOR)
|
||||||
|
.build();
|
||||||
|
|
||||||
private final ComponentLog logger;
|
private final ComponentLog logger;
|
||||||
|
|
||||||
|
@ -529,6 +538,11 @@ public class FTPTransfer implements FileTransfer {
|
||||||
inetAddress = InetAddress.getByName(remoteHostname);
|
inetAddress = InetAddress.getByName(remoteHostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final boolean useUtf8Encoding = ctx.getProperty(UTF8_ENCODING).isSet() ? ctx.getProperty(UTF8_ENCODING).asBoolean() : false;
|
||||||
|
if (useUtf8Encoding) {
|
||||||
|
client.setControlEncoding("UTF-8");
|
||||||
|
}
|
||||||
|
|
||||||
client.connect(inetAddress, ctx.getProperty(PORT).evaluateAttributeExpressions(flowFile).asInteger());
|
client.connect(inetAddress, ctx.getProperty(PORT).evaluateAttributeExpressions(flowFile).asInteger());
|
||||||
this.closed = false;
|
this.closed = false;
|
||||||
client.setDataTimeout(ctx.getProperty(DATA_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue());
|
client.setDataTimeout(ctx.getProperty(DATA_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue());
|
||||||
|
|
Loading…
Reference in New Issue