All of the examples in default/graph/launch return only one file: an HTML file, a CSV or an XLS file.
Can I return more than one file? At least, I would like to return HTML, so the user can see results and also return a csv file to the user in the same action.
I cannot find a way to do this. If I set up a second writable.channel in my graph, the graph succeeds, but I just get a blank page. I do not see the HTML or the CSV file
Thanks for any help.
-Paul
Hi Paul,
Launch Services are based on HTTP calls, which does not support more than one file downloaded at once.
A solution to this would be zipping the files and sending that through the Launch Service.
Regards,
I believe this is a Launch Service design, CloverETL Ninja; level 24.
Got an idea though. Broken down, that would look like:
-
Create an output dictionary as writable channel and content type set to something like multipart/mixed; boundary=“…”
-
Build pieces of your multipart response in different writers; or one, depending what you’d like your parts to look like (use write to port to do that)
-
Add to your raw data specific content types and boundary closures
-
Write the whole string in stream to the output
-
All of the above as dictated by W3C RFC1341 https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html
All of the above also completely untested and strictly theoretical. Let me know if that works :)) See attached screenshots as I’d imagine it.
multipart_launchservice.PNG
multipart_launchservice_2.PNG
multipart_launchservice_4.PNG
But since not so many systems are capable of consuming multipart responses; what I’d suggest is to use combination of input parameters which would format the output as desired and implement caching algorithm, so you can store the raw data and format upon next (separate) request.You’ll get the same thing with less on an headache, but multiple calls of the same LS endpoint.
Or, as Pedro suggested. Zip/Tarball bunch of files together and return it.
Is that your project requirement or what is the drive of having multipart response if you don’t mind me asking?
On top of that. I do not believe, any browser supports multipart response. And if it does, it will display HTML and the rest will ignore.
A bit old topic but I do not believe anything changed dramatically in this department… https://stackoverflow.com/questions/1806228/browser-support-of-multipart-responses
Hi Paul,
Launch Services are based on HTTP calls, which does not support more than one file downloaded at once.
A solution to this would be zipping the files and sending that through the Launch Service.
Regards,
“vazquezrosariop”
:oops: Of course that is perfect. I will just zip the files up and send them all as one download. Very nice suggestion.
Thank you.
Hi Paul,
Launch Services are based on HTTP calls, which does not support more than one file downloaded at once.
A solution to this would be zipping the files and sending that through the Launch Service.
Regards,
“vazquezrosariop”
Thanks for the suggestion. Seems like a great idea. However, I cannot figure out how I would create a zip file with multiple contents and then return it as a zip.
I can create a zip file with multiple contents, but how do I then feed that out to the dictionary?
Can you give me any suggestions or samples?
Thanks,
-Paul
Hi Paul,
You will need to read the zip folder using FlatFileReader and write the values to the writable.channel using FlatFileWriter. Since the zip folder contains multiple files with different metadata, the simplest solution is to use metadata consisting of a single field of a byte type with the fixed length. The fact that you read the data in bytes means that you don’t need to worry about the inner logical structure of the zip file. You will only need to set the most suitable size for each record. In the attached graph I have set the record size to 10000.
It’s important to note that you need to set your content type property of the dictionary to application/octet-steam (used to indicate that a body contains arbitrary binary data)
Let me know if you have any questions.
return-file.grf
I eventually solved this problem by using email attachments instead of returning the files through Launch Service.
When the graph runs, it sends the output files out as email attachments.
-Paul