Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

esb service with file download

hi,

what could be the best way to offer an excel file download via talend webservice. Could that be made via restful service like trestrequest -> {some input} -> tfileoutputexcel -> txmlmap -> trestresponse?

Any ideas?
thanks mic
Labels (4)
6 Replies
Anonymous
Not applicable
Author

Here is a very basic example that will allow you to do this. The layout of the job is shown in the screenshot below.

0683p000009MGZs.png

The configuration of the tFileInputRaw is below....

0683p000009MGYz.png

The tConvertType component converts the output from the tFileInputRaw from Object to byte[].

The tRestResponse is configured as below...


0683p000009MGaL.png

On the Advanced Settings tab you need to set some Response Headers.....

0683p000009MGaQ.png

When you run the service and call it through a browser, it will return your file.
Anonymous
Not applicable
Author

thats it. many thanks
mic
MikeP1
Contributor
Contributor

Hello,

 

I followed the instructions provided by @rhall.

However, I seem to have trouble opening the downloaded xlsx file.

I keep on getting the following error :

 

"Excel cannot open the file "workbook.xlsx" because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file."

 

So far, I’ve tried setting the content type to :

 

application/vnd.ms-excel

application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

and

application/vnd.openxml (as suggested here : https://coderanch.com/t/582495/open-source/opening-xlsx-file-downloaded-action)

 

Here is what I am trying to do:

 

0695b00000JP4e6AAD.jpg 

0695b00000JP4gvAAD.jpg0695b00000JP4ggAAD.jpg0695b00000JP4aaAAD.jpg0695b00000JP4hKAAT.jpg 

0695b00000JP4hPAAT.jpg0695b00000JP4hUAAT.jpg 

0695b00000JP4heAAD.jpg 

0695b00000JP4hoAAD.jpg 

0695b00000JP4hyAAD.jpgWhat I am doing wrong?

 

Any help would be greatly appreciated.

 

Thanks,

Mike

Anonymous
Not applicable
Author

@Mike P​ I've just tried the service as I wrote it and I got the same error as you. I then realised that I had not set up the tConvertType component properly. This is easily done. I don't see a tConvertType in your job, but maybe you just aren't showing it. Mine is configured as below....

 

The Schema

0695b00000JP4vWAAT.pngThe Manual Cast config

0695b00000JP4vMAAT.png 

Without this, it will not work.

MikeP1
Contributor
Contributor

Thanks for responding !

 

I added the tConvertType component, however I'm still getting the same error.

 

0695b00000JP51KAAT.jpg 

0695b00000JP51UAAT.jpg 

0695b00000JP51oAAD.jpg 

I also tried using a tJavaRow component to perform the conversion and mapping but I can't seem to get around this error

 

Anonymous
Not applicable
Author

Are you getting a file with data in it? Or is it zero bytes? Is the file being named as you expect? I see you are setting the Content-Disposition dynamically. Also, have you tried the original example before adding to it?

 

The Content-Type should be "application/excel". I have tested the examples you gave....

 

application/vnd.ms-excel

application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

and

application/vnd.openxml

 

.....and the second two work with my service, the first one uses the old Excel format and I get the same error as you.