Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

NIFI - Validate vame of file

Solved Go to solution

NIFI - Validate vame of file

New Contributor

Hello, is possible validate the name of the file to tingest in HDFS? I mean, i need validate the name of the file is correct and the size is > 0, it's possible?

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: NIFI - Validate vame of file

Super Guru
@Pepelu Rico

Yes we can validate the name of the file and size of file before ingesting into HDFS by using RouteOnAttribute processor.

in NiFi we are having attributes to the flowfile as

1.${filename} //gets the filename of the flowfile
2.${fileSize} //gets the size in bytes of the flowfile

In RouteOnAttribute processor add new property as

valid_files

${filename:equlas("<required_file_name>"):and(${fileSize:gt(0)})} 

In the above expression we are using NiFi expression language and checking the filename value equlas(expression language function) to <required_file_name> and checking fileSize value is greater than 0, Then only the flowfiles will be tranferred into valid_files relation.

Feed only the valid_files relation to PutHDFS processor, By using this relation we are storing only the files that satisfies the condition will be stored into HDFS.

-

If the Answer helped to resolve your issue, Click on Accept button below to accept the answer, That would be great help to Community users to find solution quickly for these kind of issues.

1 REPLY 1
Highlighted

Re: NIFI - Validate vame of file

Super Guru
@Pepelu Rico

Yes we can validate the name of the file and size of file before ingesting into HDFS by using RouteOnAttribute processor.

in NiFi we are having attributes to the flowfile as

1.${filename} //gets the filename of the flowfile
2.${fileSize} //gets the size in bytes of the flowfile

In RouteOnAttribute processor add new property as

valid_files

${filename:equlas("<required_file_name>"):and(${fileSize:gt(0)})} 

In the above expression we are using NiFi expression language and checking the filename value equlas(expression language function) to <required_file_name> and checking fileSize value is greater than 0, Then only the flowfiles will be tranferred into valid_files relation.

Feed only the valid_files relation to PutHDFS processor, By using this relation we are storing only the files that satisfies the condition will be stored into HDFS.

-

If the Answer helped to resolve your issue, Click on Accept button below to accept the answer, That would be great help to Community users to find solution quickly for these kind of issues.

Don't have an account?
Coming from Hortonworks? Activate your account here