I am using postman to POST a http request with a file in form-data and want to pass the filename as a header. With file as a sink i want to get that file and save it in the name of the header value filename which i passed in the http request. Below is what i tried with spring cloud flow and i am not getting the header "filename" in the sink side the file is getting saved in the name "null"
stream create --name myfilestream --definition "http --mapped-request-headers=foo --port=5555 | file --directory-expression="'Desktop' + 'sr'" --name-expression="headers['foo']" --deploy
Could someone throw some light on this.
If you use Kafka Binder , you should consider to use this option:
spring.cloud.stream.kafka.binder.headers
The list of custom headers that will be transported by the binder.
Default: empty.
By default custom headers aren't transported.
Related
My requirement is to accept xml data file that may be gziped in HTTPS POST request and request may be chunked.
Request body WILL have the type of application/.xml.
I am using Postman to make request and java spring to write the controller and rest of the api code.
My questions is how will my request will look like, either it will be form data with xml file in input or raw body with xml selected in postman.
I am finding it hard to make a curl for it.
Here is the example request requirement:
I need to expose a POST endpoint where the user uploads an excel file and based on some validations, I either send back the file with some information added to it along with json response OR just send status code as 200 OK(no data).
I am trying to do this in spring boot. I tried following link:
https://javadigest.wordpress.com/2012/02/13/downloading-multiple-files-using-multipart-response/
This works but needs adding boundary manually. Is there any other way to do it so that I can send both the data ?
You should use #Produces as it is written here: https://docs.oracle.com/cd/E19776-01/820-4867/ghrpv/index.html
You can define the MIME-Type of your payload.
I have a FileUpload Event that should be sent over to a http:outbound upload URL. In order to do this I have to first authenticate login URL and get the response and set the session id for outbound upload URL to execute. In my case, I have an event listener which listens for the application to publish the event of File Upload. Once it is published my listener can pick up and execute the flow. I am trying to see how this can be implemented because File Upload object would need to persisted until the Login response comes back. Thanks!
For this purpose we suggest a Header Enricher pattern. So, you place that "FileUpload Event" object into some header and restore it back to the payload when you get that session id response.
So, you add a Header Enricher before first HTTP Outbound Gateway.
After this gateway you rearange your message to place that header back into a payload and do something with a session id. (Header I guess?). And only after that your have another HTTP Outbound Gateway for uploading your file.
Apache Camel - I want to read the multipart form data request so that my Post service can read it and process it ! I cannot find any relevant data for this. Can anyone please guide
If your endpoint is using jetty component, multipart support is built-in:
The camel-jetty component supports multipart form post out of box. The
submitted form-data are mapped into the message header. Camel-jetty
creates an attachment for each uploaded file. The file name is mapped
to the name of the attachment. The content type is set as the content
type of the attachment file name.
I have a NiFi flow which needs to post the data to some other server, before posting it needs to fetch a value from my internal server or Nifi Distributed cache.
And add that Value in to Http header before posting the data, also update when gets particular error code 401.
Below is the flow I am trying, all green processor I could do but stuck at getting the value and adding in invoke http header . What are other process I can make us to achieve this .
https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.9.0/org.apache.nifi.processors.standard.InvokeHTTP/
according to documentation on http code 401 InvikeHTTP routes file to No Retry relation.
also flow file should contain some response attributes including invokehttp.status.code
so, you could use RouteOnAttribute processor to redirect flow file to your external token processor only when invokehttp.status.code=401.