Paulhbartosik
Posts: 9
Joined: Wed Sep 06, 2017 4:14 pm

Can I get multiple returned files from Launch Services?

Postby Paulhbartosik » Wed Dec 06, 2017 10:21 pm

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

vazquezrosariop
Posts: 119
Joined: Mon Feb 29, 2016 5:33 pm

Re: Can I get multiple returned files from Launch Services?

Postby vazquezrosariop » Mon Dec 18, 2017 5:48 pm

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,
---
Pedro Vazquez Rosario
CloverCARE Support
CloverETL | Rapid Data Integration

Visit us online at http://www.cloveretl.com
How to speed up communication with CloverCARE support

the_goat
Posts: 14
Joined: Fri Dec 01, 2017 6:16 am

Re: Can I get multiple returned files from Launch Services?

Postby the_goat » Thu Dec 21, 2017 8:53 am

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
Dictionary configuration
multipart_launchservice.PNG (17.86 KiB) Viewed 285 times

multipart_launchservice_2.PNG
Graph highlevel
multipart_launchservice_2.PNG (110.71 KiB) Viewed 285 times

multipart_launchservice_4.PNG
Output metadata settings
multipart_launchservice_4.PNG (48.74 KiB) Viewed 285 times


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?

the_goat
Posts: 14
Joined: Fri Dec 01, 2017 6:16 am

Re: Can I get multiple returned files from Launch Services?

Postby the_goat » Thu Dec 21, 2017 8:57 am

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

Paulhbartosik
Posts: 9
Joined: Wed Sep 06, 2017 4:14 pm

Re: Can I get multiple returned files from Launch Services?

Postby Paulhbartosik » Wed Dec 27, 2017 9:52 pm

vazquezrosariop wrote: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,


: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.

Paulhbartosik
Posts: 9
Joined: Wed Sep 06, 2017 4:14 pm

Re: Can I get multiple returned files from Launch Services?

Postby Paulhbartosik » Tue Jan 16, 2018 9:35 pm

vazquezrosariop wrote: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,


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

vazquezrosariop
Posts: 119
Joined: Mon Feb 29, 2016 5:33 pm

Re: Can I get multiple returned files from Launch Services?

Postby vazquezrosariop » Wed Jan 17, 2018 4:26 pm

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
(1.68 KiB) Downloaded 11 times
---
Pedro Vazquez Rosario
CloverCARE Support
CloverETL | Rapid Data Integration

Visit us online at http://www.cloveretl.com
How to speed up communication with CloverCARE support