I have filename and filestream saved in the SQL Server database. I want to upload this filestream as a file on AWS S3 Bucket using Apache NIFI.
Currently I am following below processors in the same sequence:
- ExcecuteSQL (Here I wrote SQL query: select filename, filestream from table)
- ConvertAvroToJson (because ExecuteSQL returns Avro format data)
- EvaluateJsonPath (To read filestream column)
- Base64EncodeContent
- PutS3Object
Now problem is, This approach doesn't convert file stream to file on S3 Bucket. It just uploads a file on s3 bucket having filestream column data. It should work like if filestream is of "png" image type then it should upload png image to s3 bucket. and If filestream is of "xlsx" type then it should upload xlsx file on s3 bucket.
maybe there is a nifi native way to insert read blob column however you could use
ExecuteGroovyScript
processor instead.add
SQL.mydb
parameter on the level of processor and link it to required DBCP pool.use following script body (have no chance to test):
the script above will execute sql select and for each received record will produce a new flow file with name and content received from db.
details about ExecuteGroovyScript processor features:
https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-groovyx-nar/1.20.0/org.apache.nifi.processors.groovyx.ExecuteGroovyScript/additionalDetails.html