โ10-04-2019 03:39 AM
hi
we have a requirement to receive a file in snaplogic where we have to provide API URL to an external team. that team will do REST post along with file attached in POST request. we are supposed receive the file and store it. we tried a number of ways but itโs not working.
we sent a text file through Postman on API POST request as an attachment, but that pipeline failed with error msg as below.
โDocument input views only accept JSON-encoded dataโ
let us know if there is a way to consume a file from such REST POST request with files attached to it
โ10-10-2019 07:54 AM
hey โ originally I was thinking that you could just write to that constant file location with maybe a timestamp or uuid to make it unique. If you add an output view to the FileWriter, then itโll respond to the request with the file locations of where things were written. Alternatively you could also use a regex to read the file names, or other parts of the content-disposition header, that are passed into your task and re-use those.
Hereโs an example pipeline that shows how that second approach would work.
post-variable-filename-example_2019_10_10.slp (6.1 KB)
a month ago
HI @tlikarish Above code isn't working for me. I tried to send .xlxs and .csv file but in mapper snap $['content-disposition'].match('filename=\"(.*)\"')[1] getting error that content-disposition not found
Appreciate your help on this issue
Anyone who know the solution can help us - appreciate your help
Thanks
a month ago
Hi Rudhiran -- the double quotes were escaped in my example. Not sure where those came from, but could you try this expression, with backslashes removed, in your mapper and see if it will work for you?
$['content-disposition'].match('filename="(.*)"')[1]
a month ago
HI @tlikarish ,
Multipart reader gives response only Content type and Content - Not the content-disposition
So we're getting error in mapper that