Created 10-09-2017 10:14 AM
Hi
I am trying to upload a file from UI and the content is received in NiFi but I am not able to maintain the filename. I am getting the filename as some integer which is by convention of the Flow file message attribute is correct. But Is there a way where I can maintain the file name, same as the file I have uploaded from UI.
Regards
S A Hameedh
Created 10-09-2017 02:10 PM
How are you uploading the file? Processors like GetFile will set the filename attribute to the same name that was on disk.
Created 10-10-2017 01:01 PM
Hi Matt,
I am using postman and in the body I am uploading a file.
Regards
S A Hameedh
Created on 10-10-2017 05:39 PM - edited 08-17-2019 08:13 PM
This is the expected behavior. Your file name is local to your client environment and NiFi have no clue on where it comes from. You need to send this information together with your file. The number that you are seeing is the ID that NiFi generated for this received flow file.
How to send data depends on your client. If I use CURL to upload data I can do
curl --form "fileupload=@/tmp/file1.txt;filename=file1.txt" localhost:7878
and I receive the following in NiFi
--------------------------2c1843649b5760e1 Content-Disposition: form-data; name="fileupload"; filename="file1.txt" Content-Type: text/plain this is file 1 --------------------------2c1843649b5760e1--
You can use ExtractGrok or ExtractText to get the filename and update the flow file attribute.
EDIT: As I said, this depends on your client. I did the same test with Postman and here's how to get the right information.
Add a header to your POST query. I added a header called originalfilename
I get this information as an attribute of my flow file
With this you only need to use UpdateAttribute processor to copy this attribute to filename.
Hope this helps