Support Questions

Find answers, ask questions, and share your expertise

How get image and correct json file in apache NiFi using post-request?

avatar
New Contributor

I need to send a file in jpeg format and a json string in post-request. Screenshots below

Без имени.png

 By sending this request, I get an incorrect data display and an incorrect type in NiFi (This works even if the application/json or image/jpeg type is explicitly specified). Below you can see the name of the mime.type attribute for two flow files. In theory, application/json and image/jpeg should have been written here.

Без имени.png

 and

Без имени.png


And the contents of the JSON file are displayed as follows:

Без имени.png
Is there any way to make sure that the file type is displayed correctly, and we can see the contents in json file?

1 REPLY 1

avatar
Contributor

As per my experience, the issue you faced could be the content-type(multipart/form-data;boundary...) is not officially supported by content-viewer page's engine.
It does support Content-Type (such as application/json, application/xml, text/plain etc.) in original/formatted mode. Other types can be viewed via hex mode.

OliverGong_1-1642154921613.png

 

OliverGong_0-1642154629938.png
Directly supported Type under original mode:

1. application/json
2. application/xml
3. text/plain
Note: you may also append the charset encoding to the specified content-type.
e.g. application/json;charset=utf-8

WORKAROUND
1. You can try to put an UpdateAttribute Processor
(Configure it with an attribute  "mime.type" along with the supported Content-Type listed above, specifying this attribute would not change the actual content, it just tells the content-viewer to depend on such way to parse and display the flowfile's content. )
2. View the flowfile's content via  Hex mode.

Hope this helps, and feel free to contact me if you have any questions.
Thanks